Compare commits
232 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f471eab1a2 | ||
|
9b13ae2399 | ||
|
06f36dc746 | ||
|
98eca9cb23 | ||
|
6268795003 | ||
|
b4f0922a7c | ||
|
aef613acd3 | ||
|
9ecfa1d252 | ||
|
e0bed1e344 | ||
|
d21fa25ab8 | ||
|
0dc1a58b24 | ||
|
f2ca70e232 | ||
|
a6bed22839 | ||
|
efd67cf80d | ||
|
15204470a8 | ||
|
48358d6a5c | ||
|
d7abb891cd | ||
|
52a44eb200 | ||
|
9b1c0a75e1 | ||
|
d75e7784e5 | ||
|
0e60c8b7e0 | ||
|
018c7b1cf4 | ||
|
af1d603374 | ||
|
884308f964 | ||
|
7269990413 | ||
|
2a90d93b17 | ||
|
6e284f8823 | ||
|
a2349fc411 | ||
|
a3964b2b40 | ||
|
226ee7c1f3 | ||
|
2c12171f46 | ||
|
d034a9c295 | ||
|
d2c7104bb3 | ||
|
570c7e8638 | ||
|
cc4578a3d3 | ||
|
1db84be66a | ||
|
77c9668fe2 | ||
|
22cf9b444e | ||
|
97798d1e47 | ||
|
f4b808456a | ||
|
6264736968 | ||
|
7a5f103bcf | ||
|
1a8307b196 | ||
|
13a1c86ae8 | ||
|
15656201d2 | ||
|
f3e372cb4c | ||
|
c781ecc437 | ||
|
daa8fff6c6 | ||
|
d481bba327 | ||
|
32b08ae04c | ||
|
f00a0356c7 | ||
|
9871800874 | ||
|
39c2c038be | ||
|
285d6488a3 | ||
|
eecbd09a46 | ||
|
8d4e4ac115 | ||
|
b77a5d4c8d | ||
|
c3b8b3e7e6 | ||
|
7123b15801 | ||
|
8a2f13d657 | ||
|
251d9fc1d7 | ||
|
5eeb9650b5 | ||
|
c0addd1d33 | ||
|
05b57278d4 | ||
|
aa3ec2fbfd | ||
|
4468516aa2 | ||
|
95d006b406 | ||
|
5b057b4bcf | ||
|
77af48e547 | ||
|
0f7f709aad | ||
|
a8c0e11cb1 | ||
|
0556da85b0 | ||
|
93652e5c6f | ||
|
f3fc1d15a3 | ||
|
3148060550 | ||
|
5f08864d1f | ||
|
184fc36a08 | ||
|
281ed99868 | ||
|
2cc4a1b326 | ||
|
c5bd08755c | ||
|
99f58f63f2 | ||
|
c2a674d2c1 | ||
|
feffc19867 | ||
|
f637e1c501 | ||
|
78240a279b | ||
|
656034d2d9 | ||
|
39a81d167e | ||
|
cb1570d162 | ||
|
8cb646cc20 | ||
|
3cccb21dc9 | ||
|
7f4a49cc44 | ||
|
e0c439fe91 | ||
|
49e233e06f | ||
|
b662dd1f92 | ||
|
700cae43ab | ||
|
1c74c6e7ac | ||
|
757a9477db | ||
|
59d43408f6 | ||
|
1d8941d008 | ||
|
17f853d99c | ||
|
6f9f25dbb2 | ||
|
0273a68587 | ||
|
58a26fcaac | ||
|
489aca03ff | ||
|
f32e19e1c6 | ||
|
57bd04b6ce | ||
|
396df93220 | ||
|
9b76b58b79 | ||
|
9fffed7160 | ||
|
fd136d5501 | ||
|
89ec1c71f0 | ||
|
fc2020c6ec | ||
|
f97635de36 | ||
|
a0a57406a2 | ||
|
5efef86cfa | ||
|
20c747753d | ||
|
08a9c61587 | ||
|
0d91b07797 | ||
|
b033da1782 | ||
|
4dcd872be5 | ||
|
7e9e2a7435 | ||
|
0b84194127 | ||
|
efd9329c81 | ||
|
5cbb820e29 | ||
|
5a0166489e | ||
|
692c9a6312 | ||
|
545d14f9a5 | ||
|
7b9e01eb2b | ||
|
8562f0ec44 | ||
|
6f59d8171f | ||
|
d29a9014f2 | ||
|
205d867e4b | ||
|
84f9490149 | ||
|
1fd4258423 | ||
|
e8a55972a7 | ||
|
aef413202e | ||
|
cbc7dadf42 | ||
|
c508ecc414 | ||
|
384a31765f | ||
|
0f2c4fc40b | ||
|
66a274452c | ||
|
12f8168d1e | ||
|
2142e1dae4 | ||
|
8d21ea55a2 | ||
|
a0da7e8a1f | ||
|
e2452d6c57 | ||
|
5173a3140d | ||
|
e44f2b7d2d | ||
|
ed78f7f4e6 | ||
|
aa198e41dd | ||
|
18b38fb58a | ||
|
5d79d8fad6 | ||
|
e7a746966d | ||
|
555f35d46f | ||
|
de77dfcbbd | ||
|
af08f16efc | ||
|
01a0f3a8cf | ||
|
f80bcdcc5c | ||
|
1ead7ce681 | ||
|
dffa56463e | ||
|
ae98d2e5ea | ||
|
5b1ef638ee | ||
|
f3be03da20 | ||
|
64128a5bcb | ||
|
0018c94a79 | ||
|
d48cb11537 | ||
|
d9f7de7a24 | ||
|
3d102a77ca | ||
|
492d70424d | ||
|
24dbeceb45 | ||
|
cabd538fdd | ||
|
9cf1c3cf05 | ||
|
c3ae221a10 | ||
|
7626d859a6 | ||
|
360311f232 | ||
|
433eedd50f | ||
|
46c53f6730 | ||
|
2b9ae0cc33 | ||
|
433a27e475 | ||
|
1de265ea5d | ||
|
854ce63358 | ||
|
170f77fada | ||
|
72b99bf1ba | ||
|
1a8583f4fc | ||
|
49e8defda1 | ||
|
e5c4e77eb0 | ||
|
8dd3f38ae9 | ||
|
044a7db370 | ||
|
8cecc626c6 | ||
|
ee26fd0e05 | ||
|
a7ea6b5925 | ||
|
2b8a804997 | ||
|
908335367e | ||
|
a7415a052e | ||
|
f51e07b196 | ||
|
5f35c539ce | ||
|
59503c6bbb | ||
|
0309fce1fd | ||
|
f6d211f779 | ||
|
f179e25cc6 | ||
|
5b478cd5f6 | ||
|
e852732ea8 | ||
|
c9718e1ec0 | ||
|
30158424e9 | ||
|
5f6d9e9f42 | ||
|
b108741a8e | ||
|
b4904cc53e | ||
|
2c6fe45847 | ||
|
fed72e4607 | ||
|
c3a4e6b3c8 | ||
|
5bfc5c1010 | ||
|
1112d66fef | ||
|
61b574f2ce | ||
|
522cdd5272 | ||
|
641bae625b | ||
|
d10e20d6d2 | ||
|
b18aa933d1 | ||
|
0f519ebf85 | ||
|
031f17b4f3 | ||
|
036f763eaa | ||
|
d137f307eb | ||
|
66048a5f27 | ||
|
b8c32e24d8 | ||
|
99d51af90f | ||
|
f47ece0725 | ||
|
975089a954 | ||
|
995230f597 | ||
|
adf7072fa8 | ||
|
40cb7cf8d6 | ||
|
d0c0630c1f | ||
|
11c829fb28 | ||
|
e0dda61501 |
3
.github/workflows/check-pr.yml
vendored
3
.github/workflows/check-pr.yml
vendored
@@ -6,7 +6,8 @@
|
||||
name: PR Bad Target
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
branches:
|
||||
- 1.0.x
|
||||
- 1.1.x
|
||||
|
12
.gitignore
vendored
12
.gitignore
vendored
@@ -22,12 +22,16 @@
|
||||
# Generated files
|
||||
_Version.h
|
||||
bdf2u8g
|
||||
marlin_config.json
|
||||
mczip.h
|
||||
*.gen
|
||||
*.sublime-workspace
|
||||
|
||||
#
|
||||
# OS
|
||||
#
|
||||
applet/
|
||||
*.DS_Store
|
||||
.DS_Store
|
||||
|
||||
#
|
||||
# Misc
|
||||
@@ -146,11 +150,13 @@ vc-fileutils.settings
|
||||
#Simulation
|
||||
imgui.ini
|
||||
eeprom.dat
|
||||
spi_flash.bin
|
||||
|
||||
#cmake
|
||||
CMakeLists.txt
|
||||
src/CMakeLists.txt
|
||||
CMakeListsPrivate.txt
|
||||
build/
|
||||
|
||||
# CLion
|
||||
cmake-build-*
|
||||
@@ -167,7 +173,3 @@ __pycache__
|
||||
|
||||
# IOLogger logs
|
||||
*_log.csv
|
||||
|
||||
# Simulation / Native
|
||||
eeprom.dat
|
||||
imgui.ini
|
||||
|
@@ -35,7 +35,7 @@
|
||||
*
|
||||
* Advanced settings can be found in Configuration_adv.h
|
||||
*/
|
||||
#define CONFIGURATION_H_VERSION 02000902
|
||||
#define CONFIGURATION_H_VERSION 02000903
|
||||
|
||||
//===========================================================================
|
||||
//============================= Getting Started =============================
|
||||
@@ -94,6 +94,11 @@
|
||||
|
||||
// @section machine
|
||||
|
||||
// Choose the name from boards.h that matches your setup
|
||||
#ifndef MOTHERBOARD
|
||||
#define MOTHERBOARD BOARD_RAMPS_14_EFB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Select the serial port on the board to use for communication with the host.
|
||||
* This allows the connection of wireless adapters (for instance) to non-default port pins.
|
||||
@@ -137,11 +142,6 @@
|
||||
// Enable the Bluetooth serial interface on AT90USB devices
|
||||
//#define BLUETOOTH
|
||||
|
||||
// Choose the name from boards.h that matches your setup
|
||||
#ifndef MOTHERBOARD
|
||||
#define MOTHERBOARD BOARD_RAMPS_14_EFB
|
||||
#endif
|
||||
|
||||
// Name displayed in the LCD "Ready" message and Info menu
|
||||
//#define CUSTOM_MACHINE_NAME "3D Printer"
|
||||
|
||||
@@ -260,7 +260,6 @@
|
||||
|
||||
#define PARKING_EXTRUDER_PARKING_X { -78, 184 } // X positions for parking the extruders
|
||||
#define PARKING_EXTRUDER_GRAB_DISTANCE 1 // (mm) Distance to move beyond the parking point to grab the extruder
|
||||
//#define MANUAL_SOLENOID_CONTROL // Manual control of docking solenoids with M380 S / M381
|
||||
|
||||
#if ENABLED(PARKING_EXTRUDER)
|
||||
|
||||
@@ -757,6 +756,7 @@
|
||||
//#define COREZX
|
||||
//#define COREZY
|
||||
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
|
||||
//#define MARKFORGED_YX
|
||||
|
||||
// Enable for a belt style printer with endless "Z" motion
|
||||
//#define BELTPRINTER
|
||||
@@ -1221,6 +1221,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Probe Enable / Disable
|
||||
* The probe only provides a triggered signal when enabled.
|
||||
*/
|
||||
//#define PROBE_ENABLE_DISABLE
|
||||
#if ENABLED(PROBE_ENABLE_DISABLE)
|
||||
//#define PROBE_ENABLE_PIN -1 // Override the default pin here
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Multiple Probing
|
||||
*
|
||||
@@ -1828,6 +1837,7 @@
|
||||
#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.
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -2376,6 +2386,11 @@
|
||||
//#define VIKI2
|
||||
//#define miniVIKI
|
||||
|
||||
//
|
||||
// Alfawise Ex8 printer LCD marked as WYH L12864 COG
|
||||
//
|
||||
//#define WYH_L12864
|
||||
|
||||
//
|
||||
// MakerLab Mini Panel with graphic
|
||||
// controller and SD support - https://reprap.org/wiki/Mini_panel
|
||||
@@ -2445,6 +2460,11 @@
|
||||
//#define FYSETC_MINI_12864_2_1 // Type A/B. NeoPixel RGB Backlight
|
||||
//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
|
||||
|
||||
//
|
||||
// BigTreeTech Mini 12864 V1.0 is an alias for FYSETC_MINI_12864_2_1. Type A/B. NeoPixel RGB Backlight.
|
||||
//
|
||||
//#define BTT_MINI_12864_V1
|
||||
|
||||
//
|
||||
// Factory display for Creality CR-10
|
||||
// https://www.aliexpress.com/item/32833148327.html
|
||||
@@ -2637,32 +2657,32 @@
|
||||
*/
|
||||
|
||||
//
|
||||
// 480x320, 3.5", SPI Display From MKS
|
||||
// Normally used in MKS Robin Nano V2
|
||||
// 480x320, 3.5", SPI Display with Rotary Encoder from MKS
|
||||
// Usually paired with MKS Robin Nano V2 & V3
|
||||
//
|
||||
//#define MKS_TS35_V2_0
|
||||
|
||||
//
|
||||
// 320x240, 2.4", FSMC Display From MKS
|
||||
// Normally used in MKS Robin Nano V1.2
|
||||
// Usually paired with MKS Robin Nano V1.2
|
||||
//
|
||||
//#define MKS_ROBIN_TFT24
|
||||
|
||||
//
|
||||
// 320x240, 2.8", FSMC Display From MKS
|
||||
// Normally used in MKS Robin Nano V1.2
|
||||
// Usually paired with MKS Robin Nano V1.2
|
||||
//
|
||||
//#define MKS_ROBIN_TFT28
|
||||
|
||||
//
|
||||
// 320x240, 3.2", FSMC Display From MKS
|
||||
// Normally used in MKS Robin Nano V1.2
|
||||
// Usually paired with MKS Robin Nano V1.2
|
||||
//
|
||||
//#define MKS_ROBIN_TFT32
|
||||
|
||||
//
|
||||
// 480x320, 3.5", FSMC Display From MKS
|
||||
// Normally used in MKS Robin Nano V1.2
|
||||
// Usually paired with MKS Robin Nano V1.2
|
||||
//
|
||||
//#define MKS_ROBIN_TFT35
|
||||
|
||||
@@ -2673,7 +2693,7 @@
|
||||
|
||||
//
|
||||
// 320x240, 3.2", FSMC Display From MKS
|
||||
// Normally used in MKS Robin
|
||||
// Usually paired with MKS Robin
|
||||
//
|
||||
//#define MKS_ROBIN_TFT_V1_1R
|
||||
|
||||
@@ -2703,10 +2723,15 @@
|
||||
//#define ANET_ET5_TFT35
|
||||
|
||||
//
|
||||
// 1024x600, 7", RGB Stock Display from BIQU-BX
|
||||
// 1024x600, 7", RGB Stock Display with Rotary Encoder from BIQU-BX
|
||||
//
|
||||
//#define BIQU_BX_TFT70
|
||||
|
||||
//
|
||||
// 480x320, 3.5", SPI Stock Display with Rotary Encoder from BIQU B1 SE Series
|
||||
//
|
||||
//#define BTT_TFT35_SPI_V1_0
|
||||
|
||||
//
|
||||
// Generic TFT with detailed options
|
||||
//
|
||||
@@ -2761,23 +2786,11 @@
|
||||
//
|
||||
// Ender-3 v2 OEM display. A DWIN display with Rotary Encoder.
|
||||
//
|
||||
//#define DWIN_CREALITY_LCD
|
||||
|
||||
//
|
||||
// Ender-3 v2 OEM display, enhanced.
|
||||
//
|
||||
//#define DWIN_CREALITY_LCD_ENHANCED
|
||||
|
||||
//
|
||||
// Ender-3 v2 OEM display with enhancements by Jacob Myers
|
||||
//
|
||||
//#define DWIN_CREALITY_LCD_JYERSUI
|
||||
|
||||
//
|
||||
// MarlinUI for Creality's DWIN display (and others)
|
||||
//
|
||||
//#define DWIN_MARLINUI_PORTRAIT
|
||||
//#define DWIN_MARLINUI_LANDSCAPE
|
||||
//#define DWIN_CREALITY_LCD // Creality UI
|
||||
//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI
|
||||
//#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers
|
||||
//#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation)
|
||||
//#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation)
|
||||
|
||||
//
|
||||
// Touch Screen Settings
|
||||
@@ -2813,6 +2826,11 @@
|
||||
//#define REPRAPWORLD_KEYPAD
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
|
||||
|
||||
//
|
||||
// EasyThreeD ET-4000+ with button input and status LED
|
||||
//
|
||||
//#define EASYTHREED_UI
|
||||
|
||||
//=============================================================================
|
||||
//=============================== Extra Features ==============================
|
||||
//=============================================================================
|
||||
@@ -2823,9 +2841,6 @@
|
||||
// :[1,2,3,4,5,6,7,8]
|
||||
//#define NUM_M106_FANS 1
|
||||
|
||||
// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
|
||||
//#define FAST_PWM_FAN
|
||||
|
||||
// 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.
|
||||
|
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* Basic settings can be found in Configuration.h
|
||||
*/
|
||||
#define CONFIGURATION_ADV_H_VERSION 02000902
|
||||
#define CONFIGURATION_ADV_H_VERSION 02000903
|
||||
|
||||
//===========================================================================
|
||||
//============================= Thermal Settings ============================
|
||||
@@ -142,11 +142,20 @@
|
||||
* FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus.
|
||||
* MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2
|
||||
* MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz.
|
||||
* MAX31865_USE_READ_ERROR_DETECTION: Detects random read errors from value spikes (a 20°C difference in less than 1sec)
|
||||
* MAX31865_USE_AUTO_MODE: Faster and more frequent reads than 1-shot, but bias voltage always on, slightly affecting RTD temperature.
|
||||
* MAX31865_MIN_SAMPLING_TIME_MSEC: in 1-shot mode, the minimum time between subsequent reads. This reduces the effect of bias voltage by leaving the sensor unpowered for longer intervals.
|
||||
* MAX31865_WIRE_OHMS: In 2-wire configurations, manually set the wire resistance for more accurate readings
|
||||
*/
|
||||
//#define TEMP_SENSOR_FORCE_HW_SPI
|
||||
//#define MAX31865_SENSOR_WIRES_0 2
|
||||
//#define MAX31865_SENSOR_WIRES_1 2
|
||||
//#define MAX31865_50HZ_FILTER
|
||||
//#define MAX31865_USE_READ_ERROR_DETECTION
|
||||
//#define MAX31865_USE_AUTO_MODE
|
||||
//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100
|
||||
//#define MAX31865_WIRE_OHMS_0 0.0f
|
||||
//#define MAX31865_WIRE_OHMS_1 0.0f
|
||||
|
||||
/**
|
||||
* Hephestos 2 24V heated bed upgrade kit.
|
||||
@@ -186,6 +195,7 @@
|
||||
|
||||
//#define CHAMBER_FAN // Enable a fan on the chamber
|
||||
#if ENABLED(CHAMBER_FAN)
|
||||
//#define CHAMBER_FAN_INDEX 2 // Index of a fan to repurpose as the chamber fan. (Default: first unused fan)
|
||||
#define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on.
|
||||
#if CHAMBER_FAN_MODE == 0
|
||||
#define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255)
|
||||
@@ -414,7 +424,7 @@
|
||||
*/
|
||||
#define AUTOTEMP
|
||||
#if ENABLED(AUTOTEMP)
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98 // Factor used to weight previous readings (0.0 < value < 1.0)
|
||||
// Turn on AUTOTEMP on M104/M109 by default using proportions set here
|
||||
//#define AUTOTEMP_PROPORTIONAL
|
||||
#if ENABLED(AUTOTEMP_PROPORTIONAL)
|
||||
@@ -539,18 +549,21 @@
|
||||
//#define FAN_MAX_PWM 128
|
||||
|
||||
/**
|
||||
* FAST PWM FAN Settings
|
||||
* Fan Fast PWM
|
||||
*
|
||||
* Use to change the FAST FAN PWM frequency (if enabled in Configuration.h)
|
||||
* Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a
|
||||
* frequency as close as possible to the desired frequency.
|
||||
* Combinations of PWM Modes, prescale values and TOP resolutions are used internally
|
||||
* to produce a frequency as close as possible to the desired frequency.
|
||||
*
|
||||
* FAST_PWM_FAN_FREQUENCY [undefined by default]
|
||||
* FAST_PWM_FAN_FREQUENCY
|
||||
* Set this to your desired frequency.
|
||||
* If left undefined this defaults to F = F_CPU/(2*255*1)
|
||||
* For AVR, if left undefined this defaults to F = F_CPU/(2*255*1)
|
||||
* i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
|
||||
* These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
|
||||
* For non AVR, if left undefined this defaults to F = 1Khz.
|
||||
* This F value is only to protect the hardware from an absence of configuration
|
||||
* and not to complete it when users are not aware that the frequency must be specifically set to support the target board.
|
||||
*
|
||||
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
|
||||
* Setting very high frequencies can damage your hardware.
|
||||
*
|
||||
* USE_OCR2A_AS_TOP [undefined by default]
|
||||
* Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2:
|
||||
@@ -560,9 +573,17 @@
|
||||
* PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.)
|
||||
* USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies.
|
||||
*/
|
||||
//#define FAST_PWM_FAN // Increase the fan PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
|
||||
#if ENABLED(FAST_PWM_FAN)
|
||||
//#define FAST_PWM_FAN_FREQUENCY 31400
|
||||
//#define FAST_PWM_FAN_FREQUENCY 31400 // Define here to override the defaults below
|
||||
//#define USE_OCR2A_AS_TOP
|
||||
#ifndef FAST_PWM_FAN_FREQUENCY
|
||||
#ifdef __AVR__
|
||||
#define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1))
|
||||
#else
|
||||
#define FAST_PWM_FAN_FREQUENCY 1000U
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -603,6 +624,40 @@
|
||||
#define COOLER_AUTO_FAN_TEMPERATURE 18
|
||||
#define COOLER_AUTO_FAN_SPEED 255
|
||||
|
||||
/**
|
||||
* Hotend Cooling Fans tachometers
|
||||
*
|
||||
* Define one or more tachometer pins to enable fan speed
|
||||
* monitoring, and reporting of fan speeds with M123.
|
||||
*
|
||||
* NOTE: Only works with fans up to 7000 RPM.
|
||||
*/
|
||||
//#define FOURWIRES_FANS // Needed with AUTO_FAN when 4-wire PWM fans are installed
|
||||
//#define E0_FAN_TACHO_PIN -1
|
||||
//#define E0_FAN_TACHO_PULLUP
|
||||
//#define E0_FAN_TACHO_PULLDOWN
|
||||
//#define E1_FAN_TACHO_PIN -1
|
||||
//#define E1_FAN_TACHO_PULLUP
|
||||
//#define E1_FAN_TACHO_PULLDOWN
|
||||
//#define E2_FAN_TACHO_PIN -1
|
||||
//#define E2_FAN_TACHO_PULLUP
|
||||
//#define E2_FAN_TACHO_PULLDOWN
|
||||
//#define E3_FAN_TACHO_PIN -1
|
||||
//#define E3_FAN_TACHO_PULLUP
|
||||
//#define E3_FAN_TACHO_PULLDOWN
|
||||
//#define E4_FAN_TACHO_PIN -1
|
||||
//#define E4_FAN_TACHO_PULLUP
|
||||
//#define E4_FAN_TACHO_PULLDOWN
|
||||
//#define E5_FAN_TACHO_PIN -1
|
||||
//#define E5_FAN_TACHO_PULLUP
|
||||
//#define E5_FAN_TACHO_PULLDOWN
|
||||
//#define E6_FAN_TACHO_PIN -1
|
||||
//#define E6_FAN_TACHO_PULLUP
|
||||
//#define E6_FAN_TACHO_PULLDOWN
|
||||
//#define E7_FAN_TACHO_PIN -1
|
||||
//#define E7_FAN_TACHO_PULLUP
|
||||
//#define E7_FAN_TACHO_PULLDOWN
|
||||
|
||||
/**
|
||||
* Part-Cooling Fan Multiplexer
|
||||
*
|
||||
@@ -853,12 +908,14 @@
|
||||
//#define BLTOUCH_FORCE_MODE_SET
|
||||
|
||||
/**
|
||||
* Use "HIGH SPEED" mode for probing.
|
||||
* Enable "HIGH SPEED" option for probing.
|
||||
* Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
|
||||
* This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians
|
||||
* might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM.
|
||||
*
|
||||
* Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset.
|
||||
*/
|
||||
//#define BLTOUCH_HS_MODE
|
||||
//#define BLTOUCH_HS_MODE true
|
||||
|
||||
// Safety: Enable voltage mode settings in the LCD menu.
|
||||
//#define BLTOUCH_LCD_VOLTAGE_MENU
|
||||
@@ -1235,6 +1292,22 @@
|
||||
// Set a convenient position to do the calibration (probing point and nozzle/bed-distance)
|
||||
//#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER }
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
// Add a calibration procedure in the Probe Offsets menu
|
||||
// to compensate for twist in the X-axis.
|
||||
//#define X_AXIS_TWIST_COMPENSATION
|
||||
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
|
||||
/**
|
||||
* Enable to init the Probe Z-Offset when starting the Wizard.
|
||||
* Use a height slightly above the estimated nozzle-to-probe Z offset.
|
||||
* For example, with an offset of -5, consider a starting height of -4.
|
||||
*/
|
||||
#define XATC_START_Z 0.0
|
||||
#define XATC_MAX_POINTS 3 // Number of points to probe in the wizard
|
||||
#define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Include a page of printer information in the LCD Main Menu
|
||||
@@ -1246,9 +1319,6 @@
|
||||
// BACK menu items keep the highlight at the top
|
||||
//#define TURBO_BACK_MENU_ITEM
|
||||
|
||||
// Add a mute option to the LCD menu
|
||||
//#define SOUND_MENU_ITEM
|
||||
|
||||
/**
|
||||
* LED Control Menu
|
||||
* Add LED Control to the LCD menu
|
||||
@@ -1280,7 +1350,11 @@
|
||||
|
||||
#endif // HAS_LCD_MENU
|
||||
|
||||
#if HAS_DISPLAY
|
||||
#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
|
||||
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
// The timeout (in ms) to return to the status screen from sub-menus
|
||||
//#define LCD_TIMEOUT_TO_STATUS 15000
|
||||
|
||||
@@ -1306,7 +1380,7 @@
|
||||
|
||||
// LCD Print Progress options
|
||||
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
|
||||
#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI)
|
||||
#if CAN_SHOW_REMAINING_TIME
|
||||
//#define SHOW_REMAINING_TIME // Display estimated time to completion
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
|
||||
@@ -1532,6 +1606,14 @@
|
||||
#define SD_FIRMWARE_UPDATE_INACTIVE_VALUE 0xFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Enable this option if you have more than ~3K of unused flash space.
|
||||
* Marlin will embed all settings in the firmware binary as compressed data.
|
||||
* Use 'M503 C' to write the settings out to the SD Card as 'mc.zip'.
|
||||
* See docs/ConfigEmbedding.md for details on how to use 'mc-apply.py'.
|
||||
*/
|
||||
//#define CONFIGURATION_EMBEDDING
|
||||
|
||||
// Add an optimized binary file transfer mode, initiated with 'M28 B1'
|
||||
//#define BINARY_FILE_TRANSFER
|
||||
|
||||
@@ -1603,7 +1685,7 @@
|
||||
* Set STATUS_EXPIRE_SECONDS to zero to never clear the status.
|
||||
* This will prevent position updates from being displayed.
|
||||
*/
|
||||
#if ENABLED(U8GLIB_ST7920)
|
||||
#if IS_U8GLIB_ST7920
|
||||
// Enable this option and reduce the value to optimize screen updates.
|
||||
// The normal delay is 10µs. Use the lowest value that still gives a reliable display.
|
||||
//#define DOGM_SPI_DELAY_US 5
|
||||
@@ -1632,7 +1714,7 @@
|
||||
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
|
||||
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
|
||||
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
|
||||
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
|
||||
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
|
||||
|
||||
// Frivolous Game Options
|
||||
//#define MARLIN_BRICKOUT
|
||||
@@ -1913,6 +1995,7 @@
|
||||
#define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed
|
||||
//#define LA_DEBUG // If enabled, this will generate debug information output over USB.
|
||||
//#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration
|
||||
//#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends.
|
||||
#endif
|
||||
|
||||
// @section leveling
|
||||
@@ -1988,59 +2071,69 @@
|
||||
|
||||
/**
|
||||
* Thermal Probe Compensation
|
||||
* Probe measurements are adjusted to compensate for temperature distortion.
|
||||
* Use G76 to calibrate this feature. Use M871 to set values manually.
|
||||
* For a more detailed explanation of the process see G76_M871.cpp.
|
||||
*
|
||||
* Adjust probe measurements to compensate for distortion associated with the temperature
|
||||
* of the probe, bed, and/or hotend.
|
||||
* Use G76 to automatically calibrate this feature for probe and bed temperatures.
|
||||
* (Extruder temperature/offset values must be calibrated manually.)
|
||||
* Use M871 to set temperature/offset values manually.
|
||||
* For more details see https://marlinfw.org/docs/features/probe_temp_compensation.html
|
||||
*/
|
||||
#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
|
||||
// Enable thermal first layer compensation using bed and probe temperatures
|
||||
#define PROBE_TEMP_COMPENSATION
|
||||
//#define PTC_PROBE // Compensate based on probe temperature
|
||||
//#define PTC_BED // Compensate based on bed temperature
|
||||
//#define PTC_HOTEND // Compensate based on hotend temperature
|
||||
|
||||
// Add additional compensation depending on hotend temperature
|
||||
// Note: this values cannot be calibrated and have to be set manually
|
||||
#if ENABLED(PROBE_TEMP_COMPENSATION)
|
||||
#if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND)
|
||||
/**
|
||||
* If the probe is outside the defined range, use linear extrapolation with the closest
|
||||
* point and the point with index PTC_LINEAR_EXTRAPOLATION. e.g., If set to 4 it will use the
|
||||
* linear extrapolation between data[0] and data[4] for values below PTC_PROBE_START.
|
||||
*/
|
||||
//#define PTC_LINEAR_EXTRAPOLATION 4
|
||||
|
||||
#if ENABLED(PTC_PROBE)
|
||||
// Probe temperature calibration generates a table of values starting at PTC_PROBE_START
|
||||
// (e.g., 30), in steps of PTC_PROBE_RES (e.g., 5) with PTC_PROBE_COUNT (e.g., 10) samples.
|
||||
#define PTC_PROBE_START 30 // (°C)
|
||||
#define PTC_PROBE_RES 5 // (°C)
|
||||
#define PTC_PROBE_COUNT 10
|
||||
#define PTC_PROBE_ZOFFS { 0 } // (µm) Z adjustments per sample
|
||||
#endif
|
||||
|
||||
#if ENABLED(PTC_BED)
|
||||
// Bed temperature calibration builds a similar table.
|
||||
#define PTC_BED_START 60 // (°C)
|
||||
#define PTC_BED_RES 5 // (°C)
|
||||
#define PTC_BED_COUNT 10
|
||||
#define PTC_BED_ZOFFS { 0 } // (µm) Z adjustments per sample
|
||||
#endif
|
||||
|
||||
#if ENABLED(PTC_HOTEND)
|
||||
// Note: There is no automatic calibration for the hotend. Use M871.
|
||||
#define PTC_HOTEND_START 180 // (°C)
|
||||
#define PTC_HOTEND_RES 5 // (°C)
|
||||
#define PTC_HOTEND_COUNT 20
|
||||
#define PTC_HOTEND_ZOFFS { 0 } // (µm) Z adjustments per sample
|
||||
#endif
|
||||
|
||||
// G76 options
|
||||
#if BOTH(PTC_PROBE, PTC_BED)
|
||||
// Park position to wait for probe cooldown
|
||||
#define PTC_PARK_POS { 0, 0, 100 }
|
||||
|
||||
// Probe position to probe and wait for probe to reach target temperature
|
||||
//#define PTC_PROBE_POS { 12.0f, 7.3f } // Example: MK52 magnetic heatbed
|
||||
#define PTC_PROBE_POS { 90, 100 }
|
||||
|
||||
// Enable additional compensation using hotend temperature
|
||||
// Note: this values cannot be calibrated automatically but have to be set manually
|
||||
//#define USE_TEMP_EXT_COMPENSATION
|
||||
|
||||
// Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START
|
||||
// (e.g., 30), in steps of PTC_SAMPLE_RES (e.g., 5) with PTC_SAMPLE_COUNT (e.g., 10) samples.
|
||||
|
||||
//#define PTC_SAMPLE_START 30 // (°C)
|
||||
//#define PTC_SAMPLE_RES 5 // (°C)
|
||||
//#define PTC_SAMPLE_COUNT 10
|
||||
|
||||
// Bed temperature calibration builds a similar table.
|
||||
|
||||
//#define BTC_SAMPLE_START 60 // (°C)
|
||||
//#define BTC_SAMPLE_RES 5 // (°C)
|
||||
//#define BTC_SAMPLE_COUNT 10
|
||||
|
||||
// The temperature the probe should be at while taking measurements during bed temperature
|
||||
// calibration.
|
||||
//#define BTC_PROBE_TEMP 30 // (°C)
|
||||
// The temperature the probe should be at while taking measurements during
|
||||
// bed temperature calibration.
|
||||
#define PTC_PROBE_TEMP 30 // (°C)
|
||||
|
||||
// Height above Z=0.0 to raise the nozzle. Lowering this can help the probe to heat faster.
|
||||
// Note: the Z=0.0 offset is determined by the probe offset which can be set using M851.
|
||||
//#define PTC_PROBE_HEATING_OFFSET 0.5
|
||||
|
||||
// Height to raise the Z-probe between heating and taking the next measurement. Some probes
|
||||
// may fail to untrigger if they have been triggered for a long time, which can be solved by
|
||||
// increasing the height the probe is raised to.
|
||||
//#define PTC_PROBE_RAISE 15
|
||||
|
||||
// If the probe is outside of the defined range, use linear extrapolation using the closest
|
||||
// point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0]
|
||||
// and data[4] to perform linear extrapolation for values below PTC_SAMPLE_START.
|
||||
//#define PTC_LINEAR_EXTRAPOLATION 4
|
||||
// Note: The Z=0.0 offset is determined by the probe Z offset (e.g., as set with M851 Z).
|
||||
#define PTC_PROBE_HEATING_OFFSET 0.5
|
||||
#endif
|
||||
#endif
|
||||
#endif // PTC_PROBE || PTC_BED || PTC_HOTEND
|
||||
|
||||
// @section extras
|
||||
|
||||
@@ -2313,6 +2406,7 @@
|
||||
*/
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1
|
||||
//#define EVENT_GCODE_TOOLCHANGE_ALWAYS_RUN // Always execute above G-code sequences. Use with caution!
|
||||
|
||||
/**
|
||||
* Tool Sensors detect when tools have been picked up or dropped.
|
||||
@@ -2335,7 +2429,7 @@
|
||||
// Longer prime to clean out a SINGLENOZZLE
|
||||
#define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length
|
||||
#define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate
|
||||
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm/min) Retract before cooling for less stringing, better wipe, etc.
|
||||
#define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc.
|
||||
|
||||
// Cool after prime to reduce stringing
|
||||
#define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip
|
||||
@@ -2596,6 +2690,7 @@
|
||||
#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
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(X2)
|
||||
@@ -2605,6 +2700,7 @@
|
||||
#define X2_RSENSE 0.11
|
||||
#define X2_CHAIN_POS -1
|
||||
//#define X2_INTERPOLATE true
|
||||
//#define X2_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Y)
|
||||
@@ -2614,6 +2710,7 @@
|
||||
#define Y_RSENSE 0.11
|
||||
#define Y_CHAIN_POS -1
|
||||
//#define Y_INTERPOLATE true
|
||||
//#define Y_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
@@ -2623,6 +2720,7 @@
|
||||
#define Y2_RSENSE 0.11
|
||||
#define Y2_CHAIN_POS -1
|
||||
//#define Y2_INTERPOLATE true
|
||||
//#define Y2_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z)
|
||||
@@ -2632,6 +2730,7 @@
|
||||
#define Z_RSENSE 0.11
|
||||
#define Z_CHAIN_POS -1
|
||||
//#define Z_INTERPOLATE true
|
||||
//#define Z_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
@@ -2641,6 +2740,7 @@
|
||||
#define Z2_RSENSE 0.11
|
||||
#define Z2_CHAIN_POS -1
|
||||
//#define Z2_INTERPOLATE true
|
||||
//#define Z2_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
@@ -2650,6 +2750,7 @@
|
||||
#define Z3_RSENSE 0.11
|
||||
#define Z3_CHAIN_POS -1
|
||||
//#define Z3_INTERPOLATE true
|
||||
//#define Z3_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
@@ -2659,6 +2760,7 @@
|
||||
#define Z4_RSENSE 0.11
|
||||
#define Z4_CHAIN_POS -1
|
||||
//#define Z4_INTERPOLATE true
|
||||
//#define Z4_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
@@ -2668,6 +2770,7 @@
|
||||
#define I_RSENSE 0.11
|
||||
#define I_CHAIN_POS -1
|
||||
//#define I_INTERPOLATE true
|
||||
//#define I_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(J)
|
||||
@@ -2677,6 +2780,7 @@
|
||||
#define J_RSENSE 0.11
|
||||
#define J_CHAIN_POS -1
|
||||
//#define J_INTERPOLATE true
|
||||
//#define J_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(K)
|
||||
@@ -2686,6 +2790,7 @@
|
||||
#define K_RSENSE 0.11
|
||||
#define K_CHAIN_POS -1
|
||||
//#define K_INTERPOLATE true
|
||||
//#define K_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
@@ -2694,6 +2799,7 @@
|
||||
#define E0_RSENSE 0.11
|
||||
#define E0_CHAIN_POS -1
|
||||
//#define E0_INTERPOLATE true
|
||||
//#define E0_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E1)
|
||||
@@ -2702,6 +2808,7 @@
|
||||
#define E1_RSENSE 0.11
|
||||
#define E1_CHAIN_POS -1
|
||||
//#define E1_INTERPOLATE true
|
||||
//#define E1_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E2)
|
||||
@@ -2710,6 +2817,7 @@
|
||||
#define E2_RSENSE 0.11
|
||||
#define E2_CHAIN_POS -1
|
||||
//#define E2_INTERPOLATE true
|
||||
//#define E2_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E3)
|
||||
@@ -2718,6 +2826,7 @@
|
||||
#define E3_RSENSE 0.11
|
||||
#define E3_CHAIN_POS -1
|
||||
//#define E3_INTERPOLATE true
|
||||
//#define E3_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E4)
|
||||
@@ -2726,6 +2835,7 @@
|
||||
#define E4_RSENSE 0.11
|
||||
#define E4_CHAIN_POS -1
|
||||
//#define E4_INTERPOLATE true
|
||||
//#define E4_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E5)
|
||||
@@ -2734,6 +2844,7 @@
|
||||
#define E5_RSENSE 0.11
|
||||
#define E5_CHAIN_POS -1
|
||||
//#define E5_INTERPOLATE true
|
||||
//#define E5_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E6)
|
||||
@@ -2742,6 +2853,7 @@
|
||||
#define E6_RSENSE 0.11
|
||||
#define E6_CHAIN_POS -1
|
||||
//#define E6_INTERPOLATE true
|
||||
//#define E6_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E7)
|
||||
@@ -2750,6 +2862,7 @@
|
||||
#define E7_RSENSE 0.11
|
||||
#define E7_CHAIN_POS -1
|
||||
//#define E7_INTERPOLATE true
|
||||
//#define E7_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -3594,6 +3707,12 @@
|
||||
*/
|
||||
//#define CNC_COORDINATE_SYSTEMS
|
||||
|
||||
/**
|
||||
* Auto-report fan speed with M123 S<seconds>
|
||||
* Requires fans with tachometer pins
|
||||
*/
|
||||
//#define AUTO_REPORT_FANS
|
||||
|
||||
/**
|
||||
* Auto-report temperatures with M155 S<seconds>
|
||||
*/
|
||||
@@ -3838,6 +3957,7 @@
|
||||
//#define HOST_PAUSE_M76
|
||||
//#define HOST_PROMPT_SUPPORT
|
||||
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||
//#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -4211,3 +4331,6 @@
|
||||
*/
|
||||
//#define SOFT_RESET_VIA_SERIAL // 'KILL' and '^X' commands will soft-reset the controller
|
||||
//#define SOFT_RESET_ON_KILL // Use a digital button to soft-reset the controller after KILL
|
||||
|
||||
// Report uncleaned reset reason from register r2 instead of MCUSR. Supported by Optiboot on AVR.
|
||||
//#define OPTIBOOT_RESET_REASON
|
||||
|
165
Marlin/Makefile
165
Marlin/Makefile
@@ -191,6 +191,134 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1034)
|
||||
# RAMPS Derivatives - ATmega1280, ATmega2560
|
||||
#
|
||||
|
||||
# 3Drag Controller
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1100)
|
||||
# Velleman K8200 Controller (derived from 3Drag Controller)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
|
||||
# Velleman K8400 Controller (derived from 3Drag Controller)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
|
||||
# Velleman K8600 Controller (Vertex Nano)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
|
||||
# Velleman K8800 Controller (Vertex Delta)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
|
||||
# 2PrintBeta BAM&DICE with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
|
||||
# 2PrintBeta BAM&DICE Due with STK drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
|
||||
# MKS BASE v1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
|
||||
# MKS BASE v1.4 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
|
||||
# MKS BASE v1.5 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
|
||||
# MKS BASE v1.6 with Allegro A4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
|
||||
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
|
||||
# MKS GEN v1.3 or 1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
|
||||
# MKS GEN L
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
|
||||
# BigTreeTech or BIQU KFB2.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
|
||||
# zrib V2.0 (Chinese RAMPS replica)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
|
||||
# zrib V5.2 (Chinese RAMPS replica)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
|
||||
# Felix 2.0+ Electronics Board (RAMPS like)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
|
||||
# Invent-A-Part RigidBoard
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
|
||||
# Invent-A-Part RigidBoard V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
|
||||
# Sainsmart 2-in-1 board
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
|
||||
# Ultimaker
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
||||
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
|
||||
MCU ?= atmega1280
|
||||
PROG_MCU ?= m1280
|
||||
# Azteeg X3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
|
||||
# Azteeg X3 Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
|
||||
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
|
||||
# Rumba
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
|
||||
# Raise3D N series Rumba derivative
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
|
||||
# Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
|
||||
# Formbot T-Rex 2 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
|
||||
# Formbot T-Rex 3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
|
||||
# Formbot Raptor
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
|
||||
# Formbot Raptor 2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
|
||||
# bq ZUM Mega 3D
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
|
||||
# MakeBoard Mini v2.1.2 by MicroMake
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
|
||||
# TriGorilla Anycubic version 1.3-based on RAMPS EFB
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
|
||||
# ... Ver 1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
|
||||
# ... Rev 1.1 (new servo pin order)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
|
||||
# Creality: Ender-4, CR-8
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
|
||||
# Creality: CR10S, CR20, CR-X
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
|
||||
# Dagoma F5
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
|
||||
# FYSETC F6 1.3
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
|
||||
# FYSETC F6 1.4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
|
||||
# Wanhao Duplicator i3 Plus
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
|
||||
# VORON Design
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
|
||||
# Tronxy TRONXY-V3-1.0
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
|
||||
# Z-Bolt X Series
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
|
||||
# TT OSCAR
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
|
||||
# Overlord/Overlord Pro
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
|
||||
# ADIMLab Gantry v1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
|
||||
# ADIMLab Gantry v2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
|
||||
# BIQU Tango V1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
|
||||
# MKS GEN L V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
|
||||
# MKS GEN L V2.1
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
|
||||
# Copymaster 3D
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1154)
|
||||
# Ortur 4
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1155)
|
||||
# Tenlog D3 Hero IDEX printer
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1156)
|
||||
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1157)
|
||||
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1158)
|
||||
# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1159)
|
||||
# Longer LK1 PRO / Alfawise U20 Pro (PRO version)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1160)
|
||||
# Longer LKx PRO / Alfawise Uxx Pro (PRO version)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1161)
|
||||
|
||||
|
||||
# 3Drag Controller
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1100)
|
||||
# Velleman K8200 Controller (derived from 3Drag Controller)
|
||||
@@ -358,20 +486,38 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1311)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1312)
|
||||
# Mega controller
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1313)
|
||||
# Geeetech GT2560 Rev B for Mecreator2
|
||||
# Geeetech GT2560 Rev A
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1314)
|
||||
# Geeetech GT2560 Rev. A
|
||||
# Geeetech GT2560 Rev A+ (with auto level probe)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1315)
|
||||
# Geeetech GT2560 Rev. A+ (with auto level probe)
|
||||
# Geeetech GT2560 Rev B
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1316)
|
||||
# Geeetech GT2560 Rev B for A10(M/D)
|
||||
# Geeetech GT2560 Rev B for A10(M/T/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1317)
|
||||
# Geeetech GT2560 Rev B for A20(M/D)
|
||||
# Geeetech GT2560 Rev B for A10(M/T/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1318)
|
||||
# Einstart retrofit
|
||||
# Geeetech GT2560 Rev B for Mecreator2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1319)
|
||||
# Wanhao 0ne+ i3 Mini
|
||||
# Geeetech GT2560 Rev B for A20(M/T/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1320)
|
||||
# Einstart retrofit
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1321)
|
||||
# Wanhao 0ne+ i3 Mini
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1322)
|
||||
# Leapfrog Xeed 2015
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1323)
|
||||
# PICA Shield (original version)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1324)
|
||||
# PICA Shield (rev C or later)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1325)
|
||||
# Intamsys 4.0 (Funmat HT)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1326)
|
||||
# Malyan M180 Mainboard Version 2 (no display function, direct gcode only)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1327)
|
||||
# Geeetech GT2560 Rev B for A20(M/T/D)
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1328)
|
||||
# Mega controller & Protoneer CNC Shield V3.00
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1329)
|
||||
|
||||
#
|
||||
# ATmega1281, ATmega2561
|
||||
@@ -445,6 +591,11 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1510)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
PROG_MCU ?= m1284p
|
||||
# ZoneStar ZMIB V2
|
||||
else ifeq ($(HARDWARE_MOTHERBOARD),1511)
|
||||
HARDWARE_VARIANT ?= Sanguino
|
||||
MCU ?= atmega1284p
|
||||
PROG_MCU ?= m1284p
|
||||
|
||||
#
|
||||
# Other ATmega644P, ATmega644, ATmega1284P
|
||||
|
@@ -28,7 +28,7 @@
|
||||
/**
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
//#define SHORT_BUILD_VERSION "2.0.9.2"
|
||||
//#define SHORT_BUILD_VERSION "2.0.9.3"
|
||||
|
||||
/**
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
@@ -41,7 +41,7 @@
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
//#define STRING_DISTRIBUTION_DATE "2021-09-03"
|
||||
//#define STRING_DISTRIBUTION_DATE "2021-12-25"
|
||||
|
||||
/**
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
|
@@ -35,12 +35,31 @@
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
//uint8_t MCUSR;
|
||||
// Don't initialize/override variable (which would happen in .init4)
|
||||
uint8_t reset_reason __attribute__((section(".noinit")));
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
__attribute__((naked)) // Don't output function pro- and epilogue
|
||||
__attribute__((used)) // Output the function, even if "not used"
|
||||
__attribute__((section(".init3"))) // Put in an early user definable section
|
||||
void HAL_save_reset_reason() {
|
||||
#if ENABLED(OPTIBOOT_RESET_REASON)
|
||||
__asm__ __volatile__(
|
||||
A("STS %0, r2")
|
||||
: "=m"(reset_reason)
|
||||
);
|
||||
#else
|
||||
reset_reason = MCUSR;
|
||||
#endif
|
||||
|
||||
// Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop
|
||||
MCUSR = 0;
|
||||
wdt_disable();
|
||||
}
|
||||
|
||||
void HAL_init() {
|
||||
// Init Servo Pins
|
||||
#define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW)
|
||||
|
@@ -91,7 +91,7 @@ typedef int8_t pin_t;
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
//extern uint8_t MCUSR;
|
||||
extern uint8_t reset_reason;
|
||||
|
||||
// Serial ports
|
||||
#ifdef USBCON
|
||||
@@ -152,21 +152,19 @@ void HAL_init();
|
||||
|
||||
//void _delay_ms(const int delay);
|
||||
|
||||
inline void HAL_clear_reset_source() { MCUSR = 0; }
|
||||
inline uint8_t HAL_get_reset_source() { return MCUSR; }
|
||||
inline void HAL_clear_reset_source() { }
|
||||
inline uint8_t HAL_get_reset_source() { return reset_reason; }
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
#ifdef DIDR2
|
||||
@@ -223,7 +221,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Sets the PWM duty cycle of the provided pin to the provided value
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
|
@@ -34,7 +34,9 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
void spiBegin() {
|
||||
#if PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
#endif
|
||||
SET_OUTPUT(SD_SCK_PIN);
|
||||
SET_INPUT(SD_MISO_PIN);
|
||||
SET_OUTPUT(SD_MOSI_PIN);
|
||||
|
@@ -22,11 +22,10 @@
|
||||
#ifdef __AVR__
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
struct Timer {
|
||||
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
|
||||
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
|
||||
@@ -55,8 +54,8 @@ Timer get_pwm_timer(const pin_t pin) {
|
||||
case TIMER1A: case TIMER1B:
|
||||
#endif
|
||||
break;
|
||||
#if defined(TCCR2) || defined(TCCR2A)
|
||||
#ifdef TCCR2
|
||||
#if HAS_TCCR2 || defined(TCCR2A)
|
||||
#if HAS_TCCR2
|
||||
case TIMER2: {
|
||||
Timer timer = {
|
||||
/*TCCRnQ*/ { &TCCR2, nullptr, nullptr },
|
||||
@@ -153,7 +152,7 @@ Timer get_pwm_timer(const pin_t pin) {
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
Timer timer = get_pwm_timer(pin);
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognized
|
||||
uint16_t size;
|
||||
if (timer.n == 2) size = 255; else size = 65535;
|
||||
|
||||
@@ -201,16 +200,10 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
res = res_temp_fast;
|
||||
j = i;
|
||||
// Set the Wave Generation Mode to FAST PWM
|
||||
if (timer.n == 2) {
|
||||
wgm = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
WGM2_FAST_PWM_OCR2A
|
||||
#else
|
||||
WGM2_FAST_PWM
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else wgm = WGM_FAST_PWM_ICRn;
|
||||
if (timer.n == 2)
|
||||
wgm = TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM);
|
||||
else
|
||||
wgm = WGM_FAST_PWM_ICRn;
|
||||
}
|
||||
// If PHASE CORRECT values are closes to desired f
|
||||
else if (f_phase_diff < f_diff) {
|
||||
@@ -218,16 +211,10 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
res = res_temp_phase_correct;
|
||||
j = i;
|
||||
// Set the Wave Generation Mode to PWM PHASE CORRECT
|
||||
if (timer.n == 2) {
|
||||
wgm = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
WGM2_PWM_PC_OCR2A
|
||||
#else
|
||||
WGM2_PWM_PC
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else wgm = WGM_PWM_PC_ICRn;
|
||||
if (timer.n == 2)
|
||||
wgm = TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_FAST_PWM);
|
||||
else
|
||||
wgm = WGM_PWM_PC_ICRn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,15 +222,17 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
_SET_CSn(timer.TCCRnQ, j);
|
||||
|
||||
if (timer.n == 2) {
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
_SET_OCRnQ(timer.OCRnQ, 0, res); // Set OCR2A value (TOP) = res
|
||||
#endif
|
||||
TERN_(USE_OCR2A_AS_TOP, _SET_OCRnQ(timer.OCRnQ, 0, res)); // Set OCR2A value (TOP) = res
|
||||
}
|
||||
else
|
||||
_SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res
|
||||
}
|
||||
|
||||
#endif // NEEDS_HARDWARE_PWM
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
#if NEEDS_HARDWARE_PWM
|
||||
|
||||
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
|
||||
// Note that digitalWrite also disables pwm output for us (sets COM bit to 0)
|
||||
if (v == 0)
|
||||
@@ -252,31 +241,20 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
|
||||
digitalWrite(pin, !invert);
|
||||
else {
|
||||
Timer timer = get_pwm_timer(pin);
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognised
|
||||
if (timer.n == 0) return; // Don't proceed if protected timer or not recognized
|
||||
// Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted)
|
||||
_SET_COMnQ(timer.TCCRnQ, (timer.q
|
||||
#ifdef TCCR2
|
||||
+ (timer.q == 2) // COM20 is on bit 4 of TCCR2, thus requires q + 1 in the macro
|
||||
#endif
|
||||
), COM_CLEAR_SET + invert
|
||||
);
|
||||
_SET_COMnQ(timer.TCCRnQ, timer.q TERN_(HAS_TCCR2, + (timer.q == 2)), COM_CLEAR_SET + invert); // COM20 is on bit 4 of TCCR2, so +1 for q==2
|
||||
const uint16_t top = timer.n == 2 ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn;
|
||||
_SET_OCRnQ(timer.OCRnQ, timer.q, uint16_t(uint32_t(v) * top / v_size)); // Scale 8/16-bit v to top value
|
||||
}
|
||||
|
||||
uint16_t top;
|
||||
if (timer.n == 2) { // if TIMER2
|
||||
top = (
|
||||
#if ENABLED(USE_OCR2A_AS_TOP)
|
||||
*timer.OCRnQ[0] // top = OCR2A
|
||||
#else
|
||||
255 // top = 0xFF (max)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
top = *timer.ICRn; // top = ICRn
|
||||
|
||||
_SET_OCRnQ(timer.OCRnQ, timer.q, v * float(top) / float(v_size)); // Scale 8/16-bit v to top value
|
||||
}
|
||||
analogWrite(pin, v);
|
||||
UNUSED(v_size);
|
||||
UNUSED(invert);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // NEEDS_HARDWARE_PWM
|
||||
#endif // __AVR__
|
||||
|
@@ -211,32 +211,32 @@ enum ClockSource2 : char {
|
||||
|
||||
// Set Clock Select bits
|
||||
// Ex: SET_CS3(PRESCALER_64);
|
||||
#ifdef TCCR2
|
||||
#define HAS_TCCR2 1
|
||||
#endif
|
||||
#define _SET_CS(T,V) (TCCR##T##B = (TCCR##T##B & ~(0x7 << CS##T##0)) | ((int(V) & 0x7) << CS##T##0))
|
||||
#define _SET_CS0(V) _SET_CS(0,V)
|
||||
#define _SET_CS1(V) _SET_CS(1,V)
|
||||
#ifdef TCCR2
|
||||
#define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20))
|
||||
#else
|
||||
#define _SET_CS2(V) _SET_CS(2,V)
|
||||
#endif
|
||||
#define _SET_CS3(V) _SET_CS(3,V)
|
||||
#define _SET_CS4(V) _SET_CS(4,V)
|
||||
#define _SET_CS5(V) _SET_CS(5,V)
|
||||
#define SET_CS0(V) _SET_CS0(CS_##V)
|
||||
#define SET_CS1(V) _SET_CS1(CS_##V)
|
||||
#ifdef TCCR2
|
||||
|
||||
#if HAS_TCCR2
|
||||
#define _SET_CS2(V) (TCCR2 = (TCCR2 & ~(0x7 << CS20)) | (int(V) << CS20))
|
||||
#define SET_CS2(V) _SET_CS2(CS2_##V)
|
||||
#else
|
||||
#define _SET_CS2(V) _SET_CS(2,V)
|
||||
#define SET_CS2(V) _SET_CS2(CS_##V)
|
||||
#endif
|
||||
|
||||
#define SET_CS3(V) _SET_CS3(CS_##V)
|
||||
#define SET_CS4(V) _SET_CS4(CS_##V)
|
||||
#define SET_CS5(V) _SET_CS5(CS_##V)
|
||||
#define SET_CS(T,V) SET_CS##T(V)
|
||||
// Runtime (see set_pwm_frequency)
|
||||
#define _SET_CSn(TCCRnQ, V) do{ \
|
||||
(*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)); \
|
||||
}while(0)
|
||||
#define _SET_CSn(TCCRnQ, V) (*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0))
|
||||
|
||||
// Set Compare Mode bits
|
||||
// Ex: SET_COMS(4,CLEAR_SET,CLEAR_SET,CLEAR_SET);
|
||||
@@ -247,21 +247,15 @@ enum ClockSource2 : char {
|
||||
#define SET_COMC(T,V) SET_COM(T,C,V)
|
||||
#define SET_COMS(T,V1,V2,V3) do{ SET_COMA(T,V1); SET_COMB(T,V2); SET_COMC(T,V3); }while(0)
|
||||
// Runtime (see set_pwm_duty)
|
||||
#define _SET_COMnQ(TCCRnQ, Q, V) do{ \
|
||||
(*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))); \
|
||||
}while(0)
|
||||
#define _SET_COMnQ(TCCRnQ, Q, V) (*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q))))
|
||||
|
||||
// Set OCRnQ register
|
||||
// Runtime (see set_pwm_duty):
|
||||
#define _SET_OCRnQ(OCRnQ, Q, V) do{ \
|
||||
(*(OCRnQ)[(Q)] = (0x0000) | (int(V) & 0xFFFF)); \
|
||||
}while(0)
|
||||
#define _SET_OCRnQ(OCRnQ, Q, V) (*(OCRnQ)[Q] = int(V) & 0xFFFF)
|
||||
|
||||
// Set ICRn register (one per timer)
|
||||
// Runtime (see set_pwm_frequency)
|
||||
#define _SET_ICRn(ICRn, V) do{ \
|
||||
(*(ICRn) = (0x0000) | (int(V) & 0xFFFF)); \
|
||||
}while(0)
|
||||
#define _SET_ICRn(ICRn, V) (*(ICRn) = int(V) & 0xFFFF)
|
||||
|
||||
// Set Noise Canceler bit
|
||||
// Ex: SET_ICNC(2,1)
|
||||
|
@@ -28,7 +28,7 @@
|
||||
/**
|
||||
* Checks for FAST PWM
|
||||
*/
|
||||
#if ENABLED(FAST_PWM_FAN) && (ENABLED(USE_OCR2A_AS_TOP) && defined(TCCR2))
|
||||
#if ALL(FAST_PWM_FAN, USE_OCR2A_AS_TOP, HAS_TCCR2)
|
||||
#error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2"
|
||||
#endif
|
||||
|
||||
|
@@ -102,7 +102,7 @@ void PRINT_ARRAY_NAME(uint8_t x) {
|
||||
return true; \
|
||||
} else return false
|
||||
|
||||
|
||||
#define ABTEST(N) defined(TCCR##N##A) && defined(COM##N##A1)
|
||||
|
||||
/**
|
||||
* Print a pin's PWM status.
|
||||
@@ -113,7 +113,7 @@ static bool pwm_status(uint8_t pin) {
|
||||
|
||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||
|
||||
#if defined(TCCR0A) && defined(COM0A1)
|
||||
#if ABTEST(0)
|
||||
#ifdef TIMER0A
|
||||
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
||||
PWM_CASE(0, A);
|
||||
@@ -122,7 +122,7 @@ static bool pwm_status(uint8_t pin) {
|
||||
PWM_CASE(0, B);
|
||||
#endif
|
||||
|
||||
#if defined(TCCR1A) && defined(COM1A1)
|
||||
#if ABTEST(1)
|
||||
PWM_CASE(1, A);
|
||||
PWM_CASE(1, B);
|
||||
#if defined(COM1C1) && defined(TIMER1C)
|
||||
@@ -130,12 +130,12 @@ static bool pwm_status(uint8_t pin) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(TCCR2A) && defined(COM2A1)
|
||||
#if ABTEST(2)
|
||||
PWM_CASE(2, A);
|
||||
PWM_CASE(2, B);
|
||||
#endif
|
||||
|
||||
#if defined(TCCR3A) && defined(COM3A1)
|
||||
#if ABTEST(3)
|
||||
PWM_CASE(3, A);
|
||||
PWM_CASE(3, B);
|
||||
#ifdef COM3C1
|
||||
@@ -149,7 +149,7 @@ static bool pwm_status(uint8_t pin) {
|
||||
PWM_CASE(4, C);
|
||||
#endif
|
||||
|
||||
#if defined(TCCR5A) && defined(COM5A1)
|
||||
#if ABTEST(5)
|
||||
PWM_CASE(5, A);
|
||||
PWM_CASE(5, B);
|
||||
PWM_CASE(5, C);
|
||||
@@ -166,16 +166,16 @@ static bool pwm_status(uint8_t pin) {
|
||||
const volatile uint8_t* const PWM_other[][3] PROGMEM = {
|
||||
{ &TCCR0A, &TCCR0B, &TIMSK0 },
|
||||
{ &TCCR1A, &TCCR1B, &TIMSK1 },
|
||||
#if defined(TCCR2A) && defined(COM2A1)
|
||||
#if ABTEST(2)
|
||||
{ &TCCR2A, &TCCR2B, &TIMSK2 },
|
||||
#endif
|
||||
#if defined(TCCR3A) && defined(COM3A1)
|
||||
#if ABTEST(3)
|
||||
{ &TCCR3A, &TCCR3B, &TIMSK3 },
|
||||
#endif
|
||||
#ifdef TCCR4A
|
||||
{ &TCCR4A, &TCCR4B, &TIMSK4 },
|
||||
#endif
|
||||
#if defined(TCCR5A) && defined(COM5A1)
|
||||
#if ABTEST(5)
|
||||
{ &TCCR5A, &TCCR5B, &TIMSK5 },
|
||||
#endif
|
||||
};
|
||||
@@ -195,11 +195,11 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
||||
{ (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 },
|
||||
#endif
|
||||
|
||||
#if defined(TCCR2A) && defined(COM2A1)
|
||||
#if ABTEST(2)
|
||||
{ &OCR2A, &OCR2B, 0 },
|
||||
#endif
|
||||
|
||||
#if defined(TCCR3A) && defined(COM3A1)
|
||||
#if ABTEST(3)
|
||||
#ifdef COM3C1
|
||||
{ (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C },
|
||||
#else
|
||||
@@ -211,7 +211,7 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
||||
{ (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C },
|
||||
#endif
|
||||
|
||||
#if defined(TCCR5A) && defined(COM5A1)
|
||||
#if ABTEST(5)
|
||||
{ (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C },
|
||||
#endif
|
||||
};
|
||||
@@ -281,7 +281,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
||||
static void pwm_details(uint8_t pin) {
|
||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||
|
||||
#if defined(TCCR0A) && defined(COM0A1)
|
||||
#if ABTEST(0)
|
||||
#ifdef TIMER0A
|
||||
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
||||
case TIMER0A: timer_prefix(0, 'A', 3); break;
|
||||
@@ -290,7 +290,7 @@ static void pwm_details(uint8_t pin) {
|
||||
case TIMER0B: timer_prefix(0, 'B', 3); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR1A) && defined(COM1A1)
|
||||
#if ABTEST(1)
|
||||
case TIMER1A: timer_prefix(1, 'A', 4); break;
|
||||
case TIMER1B: timer_prefix(1, 'B', 4); break;
|
||||
#if defined(COM1C1) && defined(TIMER1C)
|
||||
@@ -298,12 +298,12 @@ static void pwm_details(uint8_t pin) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(TCCR2A) && defined(COM2A1)
|
||||
#if ABTEST(2)
|
||||
case TIMER2A: timer_prefix(2, 'A', 3); break;
|
||||
case TIMER2B: timer_prefix(2, 'B', 3); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR3A) && defined(COM3A1)
|
||||
#if ABTEST(3)
|
||||
case TIMER3A: timer_prefix(3, 'A', 4); break;
|
||||
case TIMER3B: timer_prefix(3, 'B', 4); break;
|
||||
#ifdef COM3C1
|
||||
@@ -317,7 +317,7 @@ static void pwm_details(uint8_t pin) {
|
||||
case TIMER4C: timer_prefix(4, 'C', 4); break;
|
||||
#endif
|
||||
|
||||
#if defined(TCCR5A) && defined(COM5A1)
|
||||
#if ABTEST(5)
|
||||
case TIMER5A: timer_prefix(5, 'A', 4); break;
|
||||
case TIMER5B: timer_prefix(5, 'B', 4); break;
|
||||
case TIMER5C: timer_prefix(5, 'C', 4); break;
|
||||
@@ -351,7 +351,6 @@ static void pwm_details(uint8_t pin) {
|
||||
#endif
|
||||
} // pwm_details
|
||||
|
||||
|
||||
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
||||
int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed
|
||||
const uint8_t port = digitalPinToPort_DEBUG(pin);
|
||||
@@ -397,3 +396,5 @@ static void pwm_details(uint8_t pin) {
|
||||
|
||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||
|
||||
#undef ABTEST
|
||||
|
@@ -34,14 +34,14 @@ typedef uint16_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 1
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 1
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 0
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 0
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
|
||||
@@ -64,7 +64,7 @@ typedef uint16_t hal_timer_t;
|
||||
|
||||
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
// waveform generation = 0100 = CTC
|
||||
SET_WGM(1, CTC_OCRnA);
|
||||
|
||||
@@ -84,7 +84,7 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
|
||||
TCNT1 = 0;
|
||||
break;
|
||||
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
// Use timer0 for temperature measurement
|
||||
// Interleave temperature interrupt with millies interrupt
|
||||
OCR0B = 128;
|
||||
@@ -109,8 +109,8 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
|
||||
* (otherwise, characters will be lost due to UART overflow).
|
||||
* Then: Stepper, Endstops, Temperature, and -finally- all others.
|
||||
*/
|
||||
#define HAL_timer_isr_prologue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
||||
/* 18 cycles maximum latency */
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
|
@@ -144,6 +144,11 @@ inline void HAL_adc_init() {}//todo
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
//
|
||||
// PWM
|
||||
//
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
//
|
||||
// Pin Map
|
||||
//
|
||||
@@ -168,16 +173,14 @@ void HAL_init();
|
||||
//
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@@ -38,17 +38,17 @@ volatile static int32_t toggles;
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
|
||||
tone_pin = _pin;
|
||||
toggles = 2 * frequency * duration / 1000;
|
||||
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
|
||||
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
|
||||
}
|
||||
|
||||
void noTone(const pin_t _pin) {
|
||||
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
|
||||
HAL_timer_disable_interrupt(MF_TIMER_TONE);
|
||||
extDigitalWrite(_pin, LOW);
|
||||
}
|
||||
|
||||
HAL_TONE_TIMER_ISR() {
|
||||
static uint8_t pin_state = 0;
|
||||
HAL_timer_isr_prologue(TONE_TIMER_NUM);
|
||||
HAL_timer_isr_prologue(MF_TIMER_TONE);
|
||||
|
||||
if (toggles) {
|
||||
toggles--;
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(U8GLIB_ST7920)
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../../shared/Delay.h"
|
||||
@@ -182,5 +182,5 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
|
||||
}
|
||||
#endif // LIGHTWEIGHT_UI
|
||||
|
||||
#endif // U8GLIB_ST7920
|
||||
#endif // IS_U8GLIB_ST7920
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
|
||||
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
|
||||
|
||||
@@ -141,5 +141,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
@@ -42,7 +42,7 @@
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
|
||||
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
|
||||
{ TC0, 0, TC0_IRQn, 3}, // 0 - [servo timer5]
|
||||
{ TC0, 1, TC1_IRQn, 0}, // 1
|
||||
{ TC0, 2, TC2_IRQn, 2}, // 2 - stepper
|
||||
@@ -66,9 +66,9 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
*/
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
Tc *tc = TimerConfig[timer_num].pTimerRegs;
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
uint32_t channel = TimerConfig[timer_num].channel;
|
||||
Tc *tc = timer_config[timer_num].pTimerRegs;
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
uint32_t channel = timer_config[timer_num].channel;
|
||||
|
||||
// Disable interrupt, just in case it was already enabled
|
||||
NVIC_DisableIRQ(irq);
|
||||
@@ -86,7 +86,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
pmc_set_writeprotect(false);
|
||||
pmc_enable_periph_clk((uint32_t)irq);
|
||||
NVIC_SetPriority(irq, TimerConfig [timer_num].priority);
|
||||
NVIC_SetPriority(irq, timer_config[timer_num].priority);
|
||||
|
||||
// wave mode, reset counter on match with RC,
|
||||
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);
|
||||
@@ -105,12 +105,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
}
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
NVIC_DisableIRQ(irq);
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
@@ -125,7 +125,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
return NVIC_GetEnabledIRQ(irq);
|
||||
}
|
||||
|
||||
|
@@ -37,17 +37,17 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 2 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 2 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 4 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 4 // Timer Index for Temperature
|
||||
#endif
|
||||
#ifndef TONE_TIMER_NUM
|
||||
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
|
||||
#ifndef MF_TIMER_TONE
|
||||
#define MF_TIMER_TONE 6 // index of timer to use for beeper tones
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
||||
@@ -60,12 +60,12 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() void TC2_Handler()
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
extern const tTimerConfig TimerConfig[];
|
||||
extern const tTimerConfig timer_config[];
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -101,17 +101,17 @@ extern const tTimerConfig TimerConfig[];
|
||||
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) {
|
||||
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
|
||||
const tTimerConfig * const pConfig = &timer_config[timer_num];
|
||||
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = compare;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
|
||||
const tTimerConfig * const pConfig = &timer_config[timer_num];
|
||||
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
|
||||
const tTimerConfig * const pConfig = &timer_config[timer_num];
|
||||
return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
const tTimerConfig * const pConfig = &TimerConfig[timer_num];
|
||||
const tTimerConfig * const pConfig = &timer_config[timer_num];
|
||||
// Reading the status register clears the interrupt flag
|
||||
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -4,11 +4,12 @@
|
||||
# Windows: bossac.exe
|
||||
# Other: leave unchanged
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import platform
|
||||
current_OS = platform.system()
|
||||
|
||||
import platform
|
||||
current_OS = platform.system()
|
||||
|
||||
if current_OS == 'Windows':
|
||||
if current_OS == 'Windows':
|
||||
|
||||
Import("env")
|
||||
|
||||
|
@@ -28,6 +28,10 @@
|
||||
#include <esp_adc_cal.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#if ENABLED(USE_ESP32_TASK_WDT)
|
||||
#include <esp_task_wdt.h>
|
||||
#endif
|
||||
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "wifi.h"
|
||||
@@ -90,8 +94,24 @@ volatile int numPWMUsed = 0,
|
||||
|
||||
#endif
|
||||
|
||||
void HAL_init_board() {
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
HardwareSerial YSerial2(2);
|
||||
|
||||
void Write_EXIO(uint8_t IO, uint8_t v) {
|
||||
if (ISRS_ENABLED()) {
|
||||
DISABLE_ISRS();
|
||||
YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
|
||||
ENABLE_ISRS();
|
||||
}
|
||||
else
|
||||
YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
|
||||
}
|
||||
#endif
|
||||
|
||||
void HAL_init_board() {
|
||||
#if ENABLED(USE_ESP32_TASK_WDT)
|
||||
esp_task_wdt_init(10, true);
|
||||
#endif
|
||||
#if ENABLED(ESP3D_WIFISUPPORT)
|
||||
esp3dlib.init();
|
||||
#elif ENABLED(WIFISUPPORT)
|
||||
@@ -127,7 +147,11 @@ void HAL_init_board() {
|
||||
// Initialize the i2s peripheral only if the I2S stepper stream is enabled.
|
||||
// The following initialization is performed after Serial1 and Serial2 are defined as
|
||||
// their native pins might conflict with the i2s stream even when they are remapped.
|
||||
TERN_(I2S_STEPPER_STREAM, i2s_init());
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
YSerial2.begin(460800 * 3, SERIAL_8N1, 16, 17);
|
||||
#elif ENABLED(I2S_STEPPER_STREAM)
|
||||
i2s_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_idletask() {
|
||||
@@ -252,7 +276,7 @@ void analogWrite(pin_t pin, int value) {
|
||||
idx = numPWMUsed;
|
||||
pwmPins[idx] = pin;
|
||||
// Start timer on first use
|
||||
if (idx == 0) HAL_timer_start(PWM_TIMER_NUM, PWM_TIMER_FREQUENCY);
|
||||
if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY);
|
||||
|
||||
++numPWMUsed;
|
||||
}
|
||||
@@ -263,7 +287,7 @@ void analogWrite(pin_t pin, int value) {
|
||||
|
||||
// Handle PWM timer interrupt
|
||||
HAL_PWM_TIMER_ISR() {
|
||||
HAL_timer_isr_prologue(PWM_TIMER_NUM);
|
||||
HAL_timer_isr_prologue(MF_TIMER_PWM);
|
||||
|
||||
static uint8_t count = 0;
|
||||
|
||||
@@ -277,7 +301,7 @@ HAL_PWM_TIMER_ISR() {
|
||||
// 128 for 7 Bit resolution
|
||||
count = (count + 1) & 0x7F;
|
||||
|
||||
HAL_timer_isr_epilogue(PWM_TIMER_NUM);
|
||||
HAL_timer_isr_epilogue(MF_TIMER_PWM);
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
|
@@ -105,16 +105,14 @@ void HAL_reboot();
|
||||
|
||||
void _delay_ms(int delay);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void analogWrite(pin_t pin, int value);
|
||||
|
||||
@@ -131,6 +129,10 @@ void HAL_adc_init();
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Pin Map
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
@@ -142,6 +144,10 @@ void HAL_idletask();
|
||||
inline void HAL_init() {}
|
||||
void HAL_init_board();
|
||||
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
void Write_EXIO(uint8_t IO, uint8_t v);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Delay in cycles (used by DELAY_NS / DELAY_US)
|
||||
//
|
||||
|
@@ -53,11 +53,9 @@ static SPISettings spiConfig;
|
||||
// ------------------------
|
||||
|
||||
void spiBegin() {
|
||||
#if !PIN_EXISTS(SD_SS)
|
||||
#error "SD_SS_PIN not defined!"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
#endif
|
||||
}
|
||||
|
||||
void spiInit(uint8_t spiRate) {
|
||||
|
@@ -38,16 +38,16 @@ volatile static int32_t toggles;
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
|
||||
tone_pin = _pin;
|
||||
toggles = 2 * frequency * duration / 1000;
|
||||
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
|
||||
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
|
||||
}
|
||||
|
||||
void noTone(const pin_t _pin) {
|
||||
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
|
||||
HAL_timer_disable_interrupt(MF_TIMER_TONE);
|
||||
WRITE(_pin, LOW);
|
||||
}
|
||||
|
||||
HAL_TONE_TIMER_ISR() {
|
||||
HAL_timer_isr_prologue(TONE_TIMER_NUM);
|
||||
HAL_timer_isr_prologue(MF_TIMER_TONE);
|
||||
|
||||
if (toggles) {
|
||||
toggles--;
|
||||
|
6
Marlin/src/HAL/ESP32/esp32.csv
Normal file
6
Marlin/src/HAL/ESP32/esp32.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x180000,
|
||||
app1, app, ota_1, 0x190000, 0x180000,
|
||||
spiffs, data, spiffs, 0x310000, 0xF0000,
|
|
@@ -40,13 +40,19 @@
|
||||
// Set pin as input with pullup mode
|
||||
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
|
||||
|
||||
// Read a pin wrapper
|
||||
#define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
// Read a pin wrapper
|
||||
#define READ(IO) digitalRead(IO)
|
||||
// Write to a pin wrapper
|
||||
#define WRITE(IO, v) (IO >= 100 ? Write_EXIO(IO, v) : digitalWrite(IO, v))
|
||||
#else
|
||||
// Read a pin wrapper
|
||||
#define READ(IO) (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
|
||||
// Write to a pin wrapper
|
||||
#define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
|
||||
#endif
|
||||
|
||||
// Write to a pin wrapper
|
||||
#define WRITE(IO, v) (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
|
||||
|
||||
// Set pin as input wrapper
|
||||
// Set pin as input wrapper (0x80 | (v << 5) | (IO - 100))
|
||||
#define SET_INPUT(IO) _SET_INPUT(IO)
|
||||
|
||||
// Set pin as input with pullup wrapper
|
||||
|
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if DISABLED(USE_ESP32_EXIO)
|
||||
|
||||
#include "i2s.h"
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
@@ -62,12 +64,9 @@ uint32_t i2s_port_data = 0;
|
||||
#define I2S_EXIT_CRITICAL() portEXIT_CRITICAL(&i2s_spinlock[i2s_num])
|
||||
|
||||
static inline void gpio_matrix_out_check(uint32_t gpio, uint32_t signal_idx, bool out_inv, bool oen_inv) {
|
||||
//if pin = -1, do not need to configure
|
||||
if (gpio != -1) {
|
||||
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio], PIN_FUNC_GPIO);
|
||||
gpio_set_direction((gpio_num_t)gpio, (gpio_mode_t)GPIO_MODE_DEF_OUTPUT);
|
||||
gpio_matrix_out(gpio, signal_idx, out_inv, oen_inv);
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t i2s_reset_fifo(i2s_port_t i2s_num) {
|
||||
@@ -254,13 +253,7 @@ int i2s_init() {
|
||||
|
||||
I2S0.fifo_conf.dscr_en = 0;
|
||||
|
||||
I2S0.conf_chan.tx_chan_mod = (
|
||||
#if ENABLED(I2S_STEPPER_SPLIT_STREAM)
|
||||
4
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
I2S0.conf_chan.tx_chan_mod = TERN(I2S_STEPPER_SPLIT_STREAM, 4, 0);
|
||||
I2S0.fifo_conf.tx_fifo_mod = 0;
|
||||
I2S0.conf.tx_mono = 0;
|
||||
|
||||
@@ -311,9 +304,16 @@ int i2s_init() {
|
||||
xTaskCreatePinnedToCore(stepperTask, "StepperTask", 10000, nullptr, 1, nullptr, CONFIG_ARDUINO_RUNNING_CORE); // run I2S stepper task on same core as rest of Marlin
|
||||
|
||||
// Route the i2s pins to the appropriate GPIO
|
||||
// If a pin is not defined, no need to configure
|
||||
#if defined(I2S_DATA) && I2S_DATA >= 0
|
||||
gpio_matrix_out_check(I2S_DATA, I2S0O_DATA_OUT23_IDX, 0, 0);
|
||||
#endif
|
||||
#if defined(I2S_BCK) && I2S_BCK >= 0
|
||||
gpio_matrix_out_check(I2S_BCK, I2S0O_BCK_OUT_IDX, 0, 0);
|
||||
#endif
|
||||
#if defined(I2S_WS) && I2S_WS >= 0
|
||||
gpio_matrix_out_check(I2S_WS, I2S0O_WS_OUT_IDX, 0, 0);
|
||||
#endif
|
||||
|
||||
// Start the I2S peripheral
|
||||
return i2s_start(I2S_NUM_0);
|
||||
@@ -340,4 +340,5 @@ void i2s_push_sample() {
|
||||
dma.current[dma.rw_pos++] = i2s_port_data;
|
||||
}
|
||||
|
||||
#endif // !USE_ESP32_EXIO
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1};
|
||||
|
||||
const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
|
||||
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
|
||||
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
|
||||
{ TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
|
||||
@@ -53,7 +53,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
|
||||
// ------------------------
|
||||
|
||||
void IRAM_ATTR timer_isr(void *para) {
|
||||
const tTimerConfig& timer = TimerConfig[(int)para];
|
||||
const tTimerConfig& timer = timer_config[(int)para];
|
||||
|
||||
// Retrieve the interrupt status and the counter value
|
||||
// from the timer that reported the interrupt
|
||||
@@ -82,7 +82,7 @@ void IRAM_ATTR timer_isr(void *para) {
|
||||
* @param frequency frequency of the timer
|
||||
*/
|
||||
void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
|
||||
const tTimerConfig timer = TimerConfig[timer_num];
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
|
||||
timer_config_t config;
|
||||
config.divider = timer.divider;
|
||||
@@ -115,7 +115,7 @@ void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
|
||||
* @param count threshold at which the interrupt is triggered
|
||||
*/
|
||||
void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) {
|
||||
const tTimerConfig timer = TimerConfig[timer_num];
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
timer_set_alarm_value(timer.group, timer.idx, count);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) {
|
||||
* @return the timer current threshold for the alarm to be triggered
|
||||
*/
|
||||
hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
const tTimerConfig timer = TimerConfig[timer_num];
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
|
||||
uint64_t alarm_value;
|
||||
timer_get_alarm_value(timer.group, timer.idx, &alarm_value);
|
||||
@@ -139,7 +139,7 @@ hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
* @return the current counter of the alarm
|
||||
*/
|
||||
hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
const tTimerConfig timer = TimerConfig[timer_num];
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
uint64_t counter_value;
|
||||
timer_get_counter_value(timer.group, timer.idx, &counter_value);
|
||||
return counter_value;
|
||||
@@ -150,7 +150,7 @@ hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
* @param timer_num timer number to enable interrupts on
|
||||
*/
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
//const tTimerConfig timer = TimerConfig[timer_num];
|
||||
//const tTimerConfig timer = timer_config[timer_num];
|
||||
//timer_enable_intr(timer.group, timer.idx);
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
* @param timer_num timer number to disable interrupts on
|
||||
*/
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
//const tTimerConfig timer = TimerConfig[timer_num];
|
||||
//const tTimerConfig timer = timer_config[timer_num];
|
||||
//timer_disable_intr(timer.group, timer.idx);
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
const tTimerConfig timer = TimerConfig[timer_num];
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
return TG[timer.group]->int_ena.val | BIT(timer_num);
|
||||
}
|
||||
|
||||
|
@@ -32,20 +32,20 @@
|
||||
typedef uint64_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
#ifndef PWM_TIMER_NUM
|
||||
#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
|
||||
#ifndef MF_TIMER_PWM
|
||||
#define MF_TIMER_PWM 2 // index of timer to use for PWM outputs
|
||||
#endif
|
||||
#ifndef TONE_TIMER_NUM
|
||||
#define TONE_TIMER_NUM 3 // index of timer for beeper tones
|
||||
#ifndef MF_TIMER_TONE
|
||||
#define MF_TIMER_TONE 3 // index of timer for beeper tones
|
||||
#endif
|
||||
|
||||
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
|
||||
@@ -79,12 +79,12 @@ typedef uint64_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
||||
|
||||
#ifndef HAL_TEMP_TIMER_ISR
|
||||
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler()
|
||||
@@ -121,7 +121,7 @@ typedef struct {
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
extern const tTimerConfig TimerConfig[];
|
||||
extern const tTimerConfig timer_config[];
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -136,5 +136,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -79,16 +79,14 @@ extern MSerialT usb_serial;
|
||||
inline void HAL_init() {}
|
||||
|
||||
// Utility functions
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
#define HAL_ADC_VREF 5.0
|
||||
@@ -103,6 +101,9 @@ void HAL_adc_enable_channel(const uint8_t ch);
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Reset source
|
||||
inline void HAL_clear_reset_source(void) {}
|
||||
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
|
@@ -37,14 +37,14 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_RATE 1000000
|
||||
@@ -58,12 +58,12 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() extern "C" void TIMER0_IRQHandler()
|
||||
@@ -77,7 +77,6 @@ typedef uint32_t hal_timer_t;
|
||||
#define HAL_PWM_TIMER_ISR() extern "C" void TIMER3_IRQHandler()
|
||||
#define HAL_PWM_TIMER_IRQn
|
||||
|
||||
|
||||
void HAL_timer_init();
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
|
||||
@@ -93,5 +92,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -123,16 +123,14 @@ extern DefaultSerial1 USBSerial;
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//
|
||||
// ADC API
|
||||
|
@@ -90,15 +90,15 @@ bool PersistentStore::access_finish() {
|
||||
// to see errors that are happening in read_data / write_data
|
||||
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
|
||||
#if ENABLED(DEBUG_SD_EEPROM_EMULATION)
|
||||
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
|
||||
FSTR_P const rw_str = write ? F("write") : F("read");
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOPGM_P(rw_str);
|
||||
SERIAL_ECHOF(rw_str);
|
||||
SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
|
||||
if (total) {
|
||||
SERIAL_ECHOPGM(" f_");
|
||||
SERIAL_ECHOPGM_P(rw_str);
|
||||
SERIAL_ECHOF(rw_str);
|
||||
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
|
||||
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
|
||||
SERIAL_ECHOLNF(write ? F("written=") : F("read="), total);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM(" f_lseek()=", s);
|
||||
|
@@ -22,18 +22,20 @@
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include <pwm.h>
|
||||
|
||||
void 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))
|
||||
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
|
||||
}
|
||||
|
||||
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
|
||||
|
||||
#include <pwm.h>
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
LPC176x::pwm_set_frequency(pin, f_desired);
|
||||
}
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NEEDS_HARDWARE_PWM
|
||||
#endif // TARGET_LPC1768
|
||||
|
@@ -40,7 +40,7 @@ void HAL_timer_init() {
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
LPC_TIM0->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
|
||||
LPC_TIM0->MR0 = uint32_t(STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency
|
||||
LPC_TIM0->TCR = _BV(SBIT_CNTEN); // Counter Enable
|
||||
@@ -49,7 +49,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
NVIC_EnableIRQ(TIMER0_IRQn);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
LPC_TIM1->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
|
||||
LPC_TIM1->MR0 = uint32_t(TEMP_TIMER_RATE) / frequency;
|
||||
LPC_TIM1->TCR = _BV(SBIT_CNTEN); // Counter Enable
|
||||
|
@@ -60,17 +60,17 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((F_CPU) / 4) // frequency of timers peripherals
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
#ifndef PWM_TIMER_NUM
|
||||
#define PWM_TIMER_NUM 3 // Timer Index for PWM
|
||||
#ifndef MF_TIMER_PWM
|
||||
#define MF_TIMER_PWM 3 // Timer Index for PWM
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_RATE 1000000
|
||||
@@ -84,23 +84,23 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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(STEP_TIMER_NUM)
|
||||
#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(TEMP_TIMER_NUM)
|
||||
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_TEMP)
|
||||
#endif
|
||||
|
||||
// Timer references by index
|
||||
#define STEP_TIMER_PTR _HAL_TIMER(STEP_TIMER_NUM)
|
||||
#define TEMP_TIMER_PTR _HAL_TIMER(TEMP_TIMER_NUM)
|
||||
#define STEP_TIMER_PTR _HAL_TIMER(MF_TIMER_STEP)
|
||||
#define TEMP_TIMER_PTR _HAL_TIMER(MF_TIMER_TEMP)
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -110,38 +110,38 @@ 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 0: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0
|
||||
case 1: TEMP_TIMER_PTR->MR0 = compare; break; // Temp Timer Match Register 0
|
||||
case MF_TIMER_STEP: STEP_TIMER_PTR->MR0 = compare; break; // Stepper Timer Match Register 0
|
||||
case MF_TIMER_TEMP: TEMP_TIMER_PTR->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 0: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0
|
||||
case 1: return TEMP_TIMER_PTR->MR0; // Temp Timer Match Register 0
|
||||
case MF_TIMER_STEP: return STEP_TIMER_PTR->MR0; // Stepper Timer Match Register 0
|
||||
case MF_TIMER_TEMP: return TEMP_TIMER_PTR->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 0: return STEP_TIMER_PTR->TC; // Stepper Timer Count
|
||||
case 1: return TEMP_TIMER_PTR->TC; // Temp Timer Count
|
||||
case MF_TIMER_STEP: return STEP_TIMER_PTR->TC; // Stepper Timer Count
|
||||
case MF_TIMER_TEMP: return TEMP_TIMER_PTR->TC; // Temp Timer Count
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler
|
||||
case 1: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler
|
||||
case MF_TIMER_STEP: NVIC_EnableIRQ(TIMER0_IRQn); break; // Enable interrupt handler
|
||||
case MF_TIMER_TEMP: NVIC_EnableIRQ(TIMER1_IRQn); break; // Enable interrupt handler
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler
|
||||
case 1: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler
|
||||
case MF_TIMER_STEP: NVIC_DisableIRQ(TIMER0_IRQn); break; // Disable interrupt handler
|
||||
case MF_TIMER_TEMP: NVIC_DisableIRQ(TIMER1_IRQn); break; // Disable interrupt handler
|
||||
}
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
@@ -157,17 +157,17 @@ FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
|
||||
|
||||
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not
|
||||
case 1: return NVIC_GetEnableIRQ(TIMER1_IRQn); // Check if interrupt is enabled or not
|
||||
case MF_TIMER_STEP: return NVIC_GetEnableIRQ(TIMER0_IRQn); // Check if interrupt is enabled or not
|
||||
case MF_TIMER_TEMP: return NVIC_GetEnableIRQ(TIMER1_IRQn); // 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 0: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break;
|
||||
case 1: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break;
|
||||
case MF_TIMER_STEP: SBI(STEP_TIMER_PTR->IR, SBIT_CNTEN); break;
|
||||
case MF_TIMER_TEMP: SBI(TEMP_TIMER_PTR->IR, SBIT_CNTEN); break;
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(U8GLIB_ST7920)
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
#include <SoftwareSPI.h>
|
||||
@@ -143,5 +143,5 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // U8GLIB_ST7920
|
||||
#endif // IS_U8GLIB_ST7920
|
||||
#endif // TARGET_LPC1768
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
|
||||
#include <SoftwareSPI.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
@@ -205,5 +205,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
#endif // TARGET_LPC1768
|
||||
|
@@ -1,26 +1,30 @@
|
||||
#
|
||||
# sets output_port
|
||||
# upload_extra_script.py
|
||||
# set the output_port
|
||||
# if target_filename is found then that drive is used
|
||||
# else if target_drive is found then that drive is used
|
||||
#
|
||||
from __future__ import print_function
|
||||
|
||||
target_filename = "FIRMWARE.CUR"
|
||||
target_drive = "REARM"
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
import os,getpass,platform
|
||||
target_filename = "FIRMWARE.CUR"
|
||||
target_drive = "REARM"
|
||||
|
||||
current_OS = platform.system()
|
||||
Import("env")
|
||||
import os,getpass,platform
|
||||
|
||||
def print_error(e):
|
||||
current_OS = platform.system()
|
||||
Import("env")
|
||||
|
||||
def print_error(e):
|
||||
print('\nUnable to find destination disk (%s)\n' \
|
||||
'Please select it in platformio.ini using the upload_port keyword ' \
|
||||
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
|
||||
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
|
||||
%(e, env.get('PIOENV')))
|
||||
|
||||
def before_upload(source, target, env):
|
||||
def before_upload(source, target, env):
|
||||
try:
|
||||
#
|
||||
# Find a disk for upload
|
||||
@@ -120,4 +124,4 @@ def before_upload(source, target, env):
|
||||
except Exception as e:
|
||||
print_error(str(e))
|
||||
|
||||
env.AddPreAction("upload", before_upload)
|
||||
env.AddPreAction("upload", before_upload)
|
||||
|
@@ -133,10 +133,15 @@ void HAL_adc_enable_channel(const uint8_t ch);
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Reset source
|
||||
inline void HAL_clear_reset_source(void) {}
|
||||
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
/* ---------------- Delay in cycles */
|
||||
|
||||
#define DELAY_CYCLES(x) Kernel::delayCycles(x)
|
||||
|
@@ -37,17 +37,17 @@ typedef uint64_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
#ifndef SYSTICK_TIMER_NUM
|
||||
#define SYSTICK_TIMER_NUM 2 // Timer Index for Systick
|
||||
#ifndef MF_TIMER_SYSTICK
|
||||
#define MF_TIMER_SYSTICK 2 // Timer Index for Systick
|
||||
#endif
|
||||
#define SYSTICK_TIMER_FREQUENCY 1000
|
||||
|
||||
@@ -62,12 +62,12 @@ typedef uint64_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() extern "C" void TIMER0_IRQHandler()
|
||||
@@ -87,5 +87,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(U8GLIB_ST7920)
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
#include "../../shared/Delay.h"
|
||||
@@ -167,5 +167,5 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // U8GLIB_ST7920
|
||||
#endif // IS_U8GLIB_ST7920
|
||||
#endif // TARGET_LPC1768
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 2 // About 2 MHz
|
||||
@@ -208,8 +208,11 @@ uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif !ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB
|
||||
#elif NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {return 0;}
|
||||
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
|
||||
|
||||
#endif // __PLAT_NATIVE_SIM__
|
||||
|
@@ -127,6 +127,11 @@ void HAL_adc_init();
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
|
||||
//
|
||||
// PWM
|
||||
//
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
//
|
||||
// Pin Map
|
||||
//
|
||||
@@ -153,16 +158,14 @@ void HAL_idletask();
|
||||
//
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@@ -53,7 +53,7 @@
|
||||
static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval)
|
||||
|
||||
FORCE_INLINE static uint16_t getTimerCount() {
|
||||
Tc * const tc = TimerConfig[SERVO_TC].pTc;
|
||||
Tc * const tc = timer_config[SERVO_TC].pTc;
|
||||
|
||||
tc->COUNT16.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC;
|
||||
SYNC(tc->COUNT16.SYNCBUSY.bit.CTRLB || tc->COUNT16.SYNCBUSY.bit.COUNT);
|
||||
@@ -65,7 +65,7 @@ FORCE_INLINE static uint16_t getTimerCount() {
|
||||
// Interrupt handler for the TC
|
||||
// ----------------------------
|
||||
HAL_SERVO_TIMER_ISR() {
|
||||
Tc * const tc = TimerConfig[SERVO_TC].pTc;
|
||||
Tc * const tc = timer_config[SERVO_TC].pTc;
|
||||
const timer16_Sequence_t timer =
|
||||
#ifndef _useTimer1
|
||||
_timer2
|
||||
@@ -125,7 +125,7 @@ HAL_SERVO_TIMER_ISR() {
|
||||
}
|
||||
|
||||
void initISR(timer16_Sequence_t timer) {
|
||||
Tc * const tc = TimerConfig[SERVO_TC].pTc;
|
||||
Tc * const tc = timer_config[SERVO_TC].pTc;
|
||||
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
|
||||
|
||||
static bool initialized = false; // Servo TC has been initialized
|
||||
@@ -202,7 +202,7 @@ void initISR(timer16_Sequence_t timer) {
|
||||
}
|
||||
|
||||
void finISR(timer16_Sequence_t timer) {
|
||||
Tc * const tc = TimerConfig[SERVO_TC].pTc;
|
||||
Tc * const tc = timer_config[SERVO_TC].pTc;
|
||||
const uint8_t tcChannel = TIMER_TCCHANNEL(timer);
|
||||
|
||||
// Disable the match channel interrupt request
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#error "OnBoard SPI BUS can't be shared with other devices."
|
||||
#endif
|
||||
|
||||
#if SERVO_TC == RTC_TIMER_NUM
|
||||
#if SERVO_TC == MF_TIMER_RTC
|
||||
#error "Servos can't use RTC timer"
|
||||
#endif
|
||||
|
||||
|
@@ -31,13 +31,13 @@
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 8
|
||||
#define NUM_HARDWARE_TIMERS 9
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = {
|
||||
const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = {
|
||||
{ {.pTc=TC0}, TC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
|
||||
{ {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
|
||||
{ {.pTc=TC2}, TC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
|
||||
@@ -67,13 +67,13 @@ FORCE_INLINE void Disable_Irq(IRQn_Type irq) {
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
|
||||
// Disable interrupt, just in case it was already enabled
|
||||
Disable_Irq(irq);
|
||||
|
||||
if (timer_num == RTC_TIMER_NUM) {
|
||||
Rtc * const rtc = TimerConfig[timer_num].pRtc;
|
||||
if (timer_num == MF_TIMER_RTC) {
|
||||
Rtc * const rtc = timer_config[timer_num].pRtc;
|
||||
|
||||
// Disable timer interrupt
|
||||
rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
|
||||
@@ -101,7 +101,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
SYNC(rtc->MODE0.SYNCBUSY.bit.ENABLE);
|
||||
}
|
||||
else {
|
||||
Tc * const tc = TimerConfig[timer_num].pTc;
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
|
||||
// Disable timer interrupt
|
||||
tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt
|
||||
@@ -141,17 +141,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
}
|
||||
|
||||
// Finally, enable IRQ
|
||||
NVIC_SetPriority(irq, TimerConfig[timer_num].priority);
|
||||
NVIC_SetPriority(irq, timer_config[timer_num].priority);
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
Disable_Irq(irq);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
const IRQn_Type irq = timer_config[timer_num].IRQ_Id;
|
||||
return NVIC_GetEnabledIRQ(irq);
|
||||
}
|
||||
|
||||
|
@@ -25,21 +25,22 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Defines
|
||||
// --------------------------------------------------------------------------
|
||||
#define RTC_TIMER_NUM 8 // This is not a TC but a RTC
|
||||
|
||||
typedef uint32_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
|
||||
|
||||
#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#define MF_TIMER_RTC 8 // This is not a TC but a RTC
|
||||
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM RTC_TIMER_NUM // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
||||
@@ -52,30 +53,29 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
||||
|
||||
#define TC_PRIORITY(t) t == SERVO_TC ? 1 \
|
||||
: (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
|
||||
: (t == TEMP_TIMER_NUM) ? 6 \
|
||||
: 7
|
||||
#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \
|
||||
: (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \
|
||||
: (t == MF_TIMER_TEMP) ? 6 : 7 )
|
||||
|
||||
#define _TC_HANDLER(t) void TC##t##_Handler()
|
||||
#define TC_HANDLER(t) _TC_HANDLER(t)
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
#define HAL_STEP_TIMER_ISR() TC_HANDLER(STEP_TIMER_NUM)
|
||||
#define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP)
|
||||
#endif
|
||||
#if STEP_TIMER_NUM != PULSE_TIMER_NUM
|
||||
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(PULSE_TIMER_NUM)
|
||||
#if MF_TIMER_STEP != MF_TIMER_PULSE
|
||||
#define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE)
|
||||
#endif
|
||||
#if TEMP_TIMER_NUM == RTC_TIMER_NUM
|
||||
#if MF_TIMER_TEMP == MF_TIMER_RTC
|
||||
#define HAL_TEMP_TIMER_ISR() void RTC_Handler()
|
||||
#else
|
||||
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(TEMP_TIMER_NUM)
|
||||
#define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP)
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -95,7 +95,7 @@ typedef struct {
|
||||
// Public Variables
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
extern const tTimerConfig TimerConfig[];
|
||||
extern const tTimerConfig timer_config[];
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Public functions
|
||||
@@ -104,20 +104,20 @@ extern const tTimerConfig TimerConfig[];
|
||||
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) {
|
||||
// Should never be called with timer RTC_TIMER_NUM
|
||||
Tc * const tc = TimerConfig[timer_num].pTc;
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
tc->COUNT32.CC[0].reg = compare;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
// Should never be called with timer RTC_TIMER_NUM
|
||||
Tc * const tc = TimerConfig[timer_num].pTc;
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
return (hal_timer_t)tc->COUNT32.CC[0].reg;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
// Should never be called with timer RTC_TIMER_NUM
|
||||
Tc * const tc = TimerConfig[timer_num].pTc;
|
||||
// Should never be called with timer MF_TIMER_RTC
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
tc->COUNT32.CTRLBSET.reg = TC_CTRLBCLR_CMD_READSYNC;
|
||||
SYNC(tc->COUNT32.SYNCBUSY.bit.CTRLB || tc->COUNT32.SYNCBUSY.bit.COUNT);
|
||||
return tc->COUNT32.COUNT.reg;
|
||||
@@ -128,13 +128,13 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
if (timer_num == RTC_TIMER_NUM) {
|
||||
Rtc * const rtc = TimerConfig[timer_num].pRtc;
|
||||
if (timer_num == MF_TIMER_RTC) {
|
||||
Rtc * const rtc = timer_config[timer_num].pRtc;
|
||||
// Clear interrupt flag
|
||||
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
|
||||
}
|
||||
else {
|
||||
Tc * const tc = TimerConfig[timer_num].pTc;
|
||||
Tc * const tc = timer_config[timer_num].pTc;
|
||||
// Clear interrupt flag
|
||||
tc->COUNT32.INTFLAG.reg = TC_INTFLAG_OVF;
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRe
|
||||
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
|
||||
|
||||
// Reset the system to initiate a firmware flash
|
||||
void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
WEAK void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
|
||||
// Maple Compatibility
|
||||
volatile uint32_t systick_uptime_millis = 0;
|
||||
|
@@ -130,7 +130,11 @@
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
typedef int16_t pin_t;
|
||||
#ifdef STM32G0B1xx
|
||||
typedef int32_t pin_t;
|
||||
#else
|
||||
typedef int16_t pin_t;
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
|
||||
|
@@ -135,7 +135,7 @@ void install_min_serial() {
|
||||
HAL_min_serial_out = &TX;
|
||||
}
|
||||
|
||||
#if DISABLED(DYNAMIC_VECTORTABLE) && DISABLED(STM32F0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
|
||||
#if NONE(DYNAMIC_VECTORTABLE, STM32F0xx, STM32G0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
|
||||
extern "C" {
|
||||
__attribute__((naked)) void JumpHandler_ASM() {
|
||||
__asm__ __volatile__ (
|
||||
|
@@ -47,7 +47,9 @@ static SPISettings spiConfig;
|
||||
#include "../shared/Delay.h"
|
||||
|
||||
void spiBegin(void) {
|
||||
#if PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
#endif
|
||||
OUT_WRITE(SD_SCK_PIN, HIGH);
|
||||
SET_INPUT(SD_MISO_PIN);
|
||||
OUT_WRITE(SD_MOSI_PIN, HIGH);
|
||||
|
@@ -114,16 +114,19 @@ byte MarlinSPI::transfer(uint8_t _data) {
|
||||
return rxData;
|
||||
}
|
||||
|
||||
__STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_RXDMAEN); }
|
||||
__STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx) { SET_BIT(SPIx->CR2, SPI_CR2_TXDMAEN); }
|
||||
|
||||
uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16_t length) {
|
||||
const uint8_t ff = 0xFF;
|
||||
|
||||
//if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) //only enable if disabled
|
||||
//if (!LL_SPI_IsEnabled(_spi.handle)) // only enable if disabled
|
||||
__HAL_SPI_ENABLE(&_spi.handle);
|
||||
|
||||
if (receiveBuf) {
|
||||
setupDma(_spi.handle, _dmaRx, DMA_PERIPH_TO_MEMORY, true);
|
||||
HAL_DMA_Start(&_dmaRx, (uint32_t)&(_spi.handle.Instance->DR), (uint32_t)receiveBuf, length);
|
||||
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_RXDMAEN); /* Enable Rx DMA Request */
|
||||
LL_SPI_EnableDMAReq_RX(_spi.handle.Instance); // Enable Rx DMA Request
|
||||
}
|
||||
|
||||
// check for 2 lines transfer
|
||||
@@ -136,7 +139,7 @@ uint8_t MarlinSPI::dmaTransfer(const void *transmitBuf, void *receiveBuf, uint16
|
||||
if (transmitBuf) {
|
||||
setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, mincTransmit);
|
||||
HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length);
|
||||
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
|
||||
LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request
|
||||
}
|
||||
|
||||
if (transmitBuf) {
|
||||
@@ -160,7 +163,7 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc)
|
||||
setupDma(_spi.handle, _dmaTx, DMA_MEMORY_TO_PERIPH, minc);
|
||||
HAL_DMA_Start(&_dmaTx, (uint32_t)transmitBuf, (uint32_t)&(_spi.handle.Instance->DR), length);
|
||||
__HAL_SPI_ENABLE(&_spi.handle);
|
||||
SET_BIT(_spi.handle.Instance->CR2, SPI_CR2_TXDMAEN); /* Enable Tx DMA Request */
|
||||
LL_SPI_EnableDMAReq_TX(_spi.handle.Instance); // Enable Tx DMA Request
|
||||
HAL_DMA_PollForTransfer(&_dmaTx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
|
||||
HAL_DMA_Abort(&_dmaTx);
|
||||
// DeInit objects
|
||||
|
@@ -24,39 +24,60 @@
|
||||
|
||||
#ifdef HAL_STM32
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if NEEDS_HARDWARE_PWM
|
||||
// Array to support sticky frequency sets per timer
|
||||
static uint16_t timer_freq[TIMER_NUM];
|
||||
|
||||
#include "HAL.h"
|
||||
#include "timers.h"
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
|
||||
const PinName pin_name = digitalPinToPinName(pin);
|
||||
TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM);
|
||||
|
||||
const timer_index_t index = get_timer_index(Instance);
|
||||
const bool needs_freq = (HardwareTimer_Handle[index] == nullptr);
|
||||
if (needs_freq) // A new instance must be set to the default frequency of PWM_FREQUENCY
|
||||
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
|
||||
|
||||
HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
|
||||
const uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin_name, PinMap_PWM));
|
||||
const TimerModes_t previousMode = HT->getMode(channel);
|
||||
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1)
|
||||
HT->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin);
|
||||
|
||||
if (needs_freq && timer_freq[index] == 0) // If the timer is unconfigured and no freq is set then default PWM_FREQUENCY
|
||||
set_pwm_frequency(pin_name, PWM_FREQUENCY); // Set the frequency and save the value to the assigned index no.
|
||||
|
||||
// Note the resolution is sticky here, the input can be upto 16 bits and that would require RESOLUTION_16B_COMPARE_FORMAT (16)
|
||||
// If such a need were to manifest then we would need to calc the resolution based on the v_size parameter and add code for it.
|
||||
const uint16_t value = invert ? v_size - v : v;
|
||||
HT->setCaptureCompare(channel, value, RESOLUTION_8B_COMPARE_FORMAT); // Sets the duty, the calc is done in the library :)
|
||||
pinmap_pinout(pin_name, PinMap_PWM); // Make sure the pin output state is set.
|
||||
if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) HT->resume();
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
|
||||
const PinName pin_name = digitalPinToPinName(pin);
|
||||
TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
|
||||
const timer_index_t index = get_timer_index(Instance);
|
||||
|
||||
PinName pin_name = digitalPinToPinName(pin);
|
||||
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
|
||||
// Protect used timers.
|
||||
#ifdef STEP_TIMER
|
||||
if (index == TIMER_INDEX(STEP_TIMER)) return;
|
||||
#endif
|
||||
#ifdef TEMP_TIMER
|
||||
if (index == TIMER_INDEX(TEMP_TIMER)) return;
|
||||
#endif
|
||||
#if defined(PULSE_TIMER) && MF_TIMER_PULSE != MF_TIMER_STEP
|
||||
if (index == TIMER_INDEX(PULSE_TIMER)) return;
|
||||
#endif
|
||||
|
||||
LOOP_S_L_N(i, 0, NUM_HARDWARE_TIMERS) // Protect used timers
|
||||
if (timer_instance[i] && timer_instance[i]->getHandle()->Instance == Instance)
|
||||
return;
|
||||
|
||||
pwm_start(pin_name, f_desired, 0, RESOLUTION_8B_COMPARE_FORMAT);
|
||||
if (HardwareTimer_Handle[index] == nullptr) // If frequency is set before duty we need to create a handle here.
|
||||
HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM));
|
||||
HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this);
|
||||
HT->setOverflow(f_desired, HERTZ_FORMAT);
|
||||
timer_freq[index] = f_desired; // Save the last frequency so duty will not set the default for this timer number.
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
PinName pin_name = digitalPinToPinName(pin);
|
||||
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM);
|
||||
uint16_t adj_val = Instance->ARR * v / v_size;
|
||||
if (invert) adj_val = Instance->ARR - adj_val;
|
||||
|
||||
switch (get_pwm_channel(pin_name)) {
|
||||
case TIM_CHANNEL_1: LL_TIM_OC_SetCompareCH1(Instance, adj_val); break;
|
||||
case TIM_CHANNEL_2: LL_TIM_OC_SetCompareCH2(Instance, adj_val); break;
|
||||
case TIM_CHANNEL_3: LL_TIM_OC_SetCompareCH3(Instance, adj_val); break;
|
||||
case TIM_CHANNEL_4: LL_TIM_OC_SetCompareCH4(Instance, adj_val); break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NEEDS_HARDWARE_PWM
|
||||
#endif // HAL_STM32
|
||||
|
@@ -161,11 +161,11 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
#if TFT_MISO_PIN != TFT_MOSI_PIN
|
||||
//if (hspi->Init.Direction == SPI_DIRECTION_2LINES) {
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
|
||||
SPIx.Instance->DR = 0;
|
||||
//}
|
||||
#endif
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
|
||||
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {}
|
||||
Data = (Data << 8) | SPIx.Instance->DR;
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ bool TFT_SPI::isBusy() {
|
||||
|
||||
void TFT_SPI::Abort() {
|
||||
// Wait for any running spi
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
|
||||
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
|
||||
while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {}
|
||||
// First, abort any running dma
|
||||
HAL_DMA_Abort(&DMAtx);
|
||||
// DeInit objects
|
||||
@@ -214,8 +214,8 @@ void TFT_SPI::Transmit(uint16_t Data) {
|
||||
|
||||
SPIx.Instance->DR = Data;
|
||||
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||
while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
|
||||
while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {}
|
||||
while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {}
|
||||
|
||||
if (TFT_MISO_PIN != TFT_MOSI_PIN)
|
||||
__HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read
|
||||
|
@@ -67,7 +67,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef STM32F0xx
|
||||
#if defined(STM32F0xx) || defined(STM32G0xx)
|
||||
#define MCU_STEP_TIMER 16
|
||||
#define MCU_TEMP_TIMER 17
|
||||
#elif defined(STM32F1xx)
|
||||
@@ -97,9 +97,15 @@
|
||||
#define STEP_TIMER_DEV _TIMER_DEV(STEP_TIMER)
|
||||
#define TEMP_TIMER_DEV _TIMER_DEV(TEMP_TIMER)
|
||||
|
||||
// ------------------------
|
||||
// --------------------------------------------------------------------------
|
||||
// Local defines
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 2
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
|
||||
|
||||
@@ -110,7 +116,7 @@ HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { nullptr };
|
||||
uint32_t GetStepperTimerClkFreq() {
|
||||
// Timer input clocks vary between devices, and in some cases between timers on the same device.
|
||||
// Retrieve at runtime to ensure device compatibility. Cache result to avoid repeated overhead.
|
||||
static uint32_t clkfreq = timer_instance[STEP_TIMER_NUM]->getTimerClkFreq();
|
||||
static uint32_t clkfreq = timer_instance[MF_TIMER_STEP]->getTimerClkFreq();
|
||||
return clkfreq;
|
||||
}
|
||||
|
||||
@@ -118,7 +124,7 @@ uint32_t GetStepperTimerClkFreq() {
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
if (!HAL_timer_initialized(timer_num)) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: // STEPPER TIMER - use a 32bit timer if possible
|
||||
case MF_TIMER_STEP: // STEPPER TIMER - use a 32bit timer if possible
|
||||
timer_instance[timer_num] = new HardwareTimer(STEP_TIMER_DEV);
|
||||
/* Set the prescaler to the final desired value.
|
||||
* This will change the effective ISR callback frequency but when
|
||||
@@ -137,7 +143,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
|
||||
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
|
||||
break;
|
||||
case TEMP_TIMER_NUM: // TEMP TIMER - any available 16bit timer
|
||||
case MF_TIMER_TEMP: // TEMP TIMER - any available 16bit timer
|
||||
timer_instance[timer_num] = new HardwareTimer(TEMP_TIMER_DEV);
|
||||
// The prescale factor is computed automatically for HERTZ_FORMAT
|
||||
timer_instance[timer_num]->setOverflow(frequency, HERTZ_FORMAT);
|
||||
@@ -157,10 +163,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
// These calls can be removed and replaced with
|
||||
// timer_instance[timer_num]->setInterruptPriority
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
|
||||
break;
|
||||
}
|
||||
@@ -170,10 +176,10 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_instance[timer_num]->attachInterrupt(Temp_Handler);
|
||||
break;
|
||||
}
|
||||
|
@@ -40,17 +40,13 @@
|
||||
#define hal_timer_t uint32_t
|
||||
#define HAL_TIMER_TYPE_MAX UINT16_MAX
|
||||
|
||||
#define NUM_HARDWARE_TIMERS 2
|
||||
// Marlin timer_instance[] content (unrelated to timer selection)
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#endif
|
||||
#define TIMER_INDEX_(T) TIMER##T##_INDEX // TIMER#_INDEX enums (timer_index_t) depend on TIM#_BASE defines.
|
||||
#define TIMER_INDEX(T) TIMER_INDEX_(T) // Convert Timer ID to HardwareTimer_Handle index.
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000 // Temperature::isr() is expected to be called at around 1kHz
|
||||
|
||||
@@ -64,12 +60,12 @@ extern uint32_t GetStepperTimerClkFreq();
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
||||
|
||||
extern void Step_Handler();
|
||||
extern void Temp_Handler();
|
||||
@@ -120,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_prologue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -449,8 +449,7 @@ uint16_t analogRead(pin_t pin) {
|
||||
|
||||
// Wrapper to maple unprotected analogWrite
|
||||
void analogWrite(pin_t pin, int pwm_val8) {
|
||||
if (PWM_PIN(pin))
|
||||
analogWrite(uint8_t(pin), pwm_val8);
|
||||
if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8);
|
||||
}
|
||||
|
||||
void HAL_reboot() { nvic_sys_reset(); }
|
||||
|
@@ -264,6 +264,9 @@ void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!?
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
void flashFirmware(const int16_t);
|
||||
|
||||
#ifndef PWM_FREQUENCY
|
||||
#define PWM_FREQUENCY 1000 // Default PWM Frequency
|
||||
#endif
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
|
||||
/**
|
||||
@@ -278,5 +281,6 @@ void set_pwm_frequency(const pin_t pin, int f_desired);
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
* The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired.
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
@@ -60,7 +60,7 @@ uint8_t ServoCount = 0;
|
||||
#define US_TO_ANGLE(us) int16_t(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, minAngle, maxAngle))
|
||||
|
||||
void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) {
|
||||
#ifdef SERVO0_TIMER_NUM
|
||||
#ifdef MF_TIMER_SERVO0
|
||||
if (servoIndex == 0) {
|
||||
pwmSetDuty(duty_cycle);
|
||||
return;
|
||||
@@ -74,7 +74,7 @@ void libServo::servoWrite(uint8_t inPin, uint16_t duty_cycle) {
|
||||
|
||||
libServo::libServo() {
|
||||
servoIndex = ServoCount < MAX_SERVOS ? ServoCount++ : INVALID_SERVO;
|
||||
timer_set_interrupt_priority(SERVO0_TIMER_NUM, SERVO0_TIMER_IRQ_PRIO);
|
||||
HAL_timer_set_interrupt_priority(MF_TIMER_SERVO0, SERVO0_TIMER_IRQ_PRIO);
|
||||
}
|
||||
|
||||
bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32_t inMaxAngle) {
|
||||
@@ -85,7 +85,7 @@ bool libServo::attach(const int32_t inPin, const int32_t inMinAngle, const int32
|
||||
maxAngle = inMaxAngle;
|
||||
angle = -1;
|
||||
|
||||
#ifdef SERVO0_TIMER_NUM
|
||||
#ifdef MF_TIMER_SERVO0
|
||||
if (servoIndex == 0 && setupSoftPWM(inPin)) {
|
||||
pin = inPin; // set attached()
|
||||
return true;
|
||||
@@ -119,7 +119,7 @@ bool libServo::detach() {
|
||||
|
||||
int32_t libServo::read() const {
|
||||
if (attached()) {
|
||||
#ifdef SERVO0_TIMER_NUM
|
||||
#ifdef MF_TIMER_SERVO0
|
||||
if (servoIndex == 0) return angle;
|
||||
#endif
|
||||
timer_dev *tdev = PIN_MAP[pin].timer_device;
|
||||
@@ -141,9 +141,9 @@ void libServo::move(const int32_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SERVO0_TIMER_NUM
|
||||
#ifdef MF_TIMER_SERVO0
|
||||
extern "C" void Servo_IRQHandler() {
|
||||
static timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
|
||||
static timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
|
||||
uint16_t SR = timer_get_status(tdev);
|
||||
if (SR & TIMER_SR_CC1IF) { // channel 1 off
|
||||
#ifdef SERVO0_PWM_OD
|
||||
@@ -164,7 +164,7 @@ void libServo::move(const int32_t value) {
|
||||
}
|
||||
|
||||
bool libServo::setupSoftPWM(const int32_t inPin) {
|
||||
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
|
||||
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
|
||||
if (!tdev) return false;
|
||||
#ifdef SERVO0_PWM_OD
|
||||
OUT_WRITE_OD(inPin, 1);
|
||||
@@ -189,7 +189,7 @@ void libServo::move(const int32_t value) {
|
||||
}
|
||||
|
||||
void libServo::pwmSetDuty(const uint16_t duty_cycle) {
|
||||
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
|
||||
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
|
||||
timer_set_compare(tdev, 1, duty_cycle);
|
||||
timer_generate_update(tdev);
|
||||
if (duty_cycle) {
|
||||
@@ -208,7 +208,7 @@ void libServo::move(const int32_t value) {
|
||||
}
|
||||
|
||||
void libServo::pauseSoftPWM() { // detach
|
||||
timer_dev *tdev = get_timer_dev(SERVO0_TIMER_NUM);
|
||||
timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0);
|
||||
timer_pause(tdev);
|
||||
pwmSetDuty(0);
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@ if __name__ == "__main__":
|
||||
|
||||
# extra script for linker options
|
||||
else:
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
from SCons.Script import DefaultEnvironment
|
||||
env = DefaultEnvironment()
|
||||
env.Append(
|
||||
|
@@ -23,30 +23,54 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if NEEDS_HARDWARE_PWM
|
||||
|
||||
#include <pwm.h>
|
||||
#include "HAL.h"
|
||||
#include "timers.h"
|
||||
|
||||
#define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E)
|
||||
|
||||
static uint16_t timer_freq[NR_TIMERS];
|
||||
|
||||
inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) {
|
||||
*timer_ptr = PIN_MAP[pin].timer_device;
|
||||
for (uint8_t i = 0; i < NR_TIMERS; i++) if (*timer_ptr == HAL_get_timer_dev(i))
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
if (!PWM_PIN(pin)) return;
|
||||
|
||||
timer_dev *timer; UNUSED(timer);
|
||||
if (timer_freq[timer_and_index_for_pin(pin, &timer)] == 0)
|
||||
set_pwm_frequency(pin, PWM_FREQUENCY);
|
||||
|
||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||
const uint16_t duty = invert ? v_size - v : v;
|
||||
timer_set_compare(timer, channel, duty);
|
||||
timer_set_mode(timer, channel, TIMER_PWM); // PWM Output Mode
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
|
||||
|
||||
timer_dev *timer = PIN_MAP[pin].timer_device;
|
||||
uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||
timer_dev *timer; UNUSED(timer);
|
||||
timer_freq[timer_and_index_for_pin(pin, &timer)] = f_desired;
|
||||
|
||||
// Protect used timers
|
||||
if (timer == get_timer_dev(TEMP_TIMER_NUM)) return;
|
||||
if (timer == get_timer_dev(STEP_TIMER_NUM)) return;
|
||||
#if PULSE_TIMER_NUM != STEP_TIMER_NUM
|
||||
if (timer == get_timer_dev(PULSE_TIMER_NUM)) return;
|
||||
if (timer == HAL_get_timer_dev(MF_TIMER_TEMP)) return;
|
||||
if (timer == HAL_get_timer_dev(MF_TIMER_STEP)) return;
|
||||
#if MF_TIMER_PULSE != MF_TIMER_STEP
|
||||
if (timer == HAL_get_timer_dev(MF_TIMER_PULSE)) return;
|
||||
#endif
|
||||
|
||||
if (!(timer->regs.bas->SR & TIMER_CR1_CEN)) // Ensure the timer is enabled
|
||||
timer_init(timer);
|
||||
|
||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||
timer_set_mode(timer, channel, TIMER_PWM);
|
||||
uint16_t preload = 255; // Lock 255 PWM resolution for high frequencies
|
||||
// Preload (resolution) cannot be equal to duty of 255 otherwise it may not result in digital off or on.
|
||||
uint16_t preload = 254;
|
||||
int32_t prescaler = (HAL_TIMER_RATE) / (preload + 1) / f_desired - 1;
|
||||
if (prescaler > 65535) { // For low frequencies increase prescaler
|
||||
prescaler = 65535;
|
||||
@@ -57,12 +81,4 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||
timer_set_prescaler(timer, prescaler);
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
timer_dev *timer = PIN_MAP[pin].timer_device;
|
||||
uint16_t max_val = timer->regs.bas->ARR * v / v_size;
|
||||
if (invert) max_val = v_size - max_val;
|
||||
pwmWrite(pin, max_val);
|
||||
}
|
||||
|
||||
#endif // NEEDS_HARDWARE_PWM
|
||||
#endif // __STM32F1__
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#error "SERIAL_STATS_DROPPED_RX is not supported on the STM32F1 platform."
|
||||
#endif
|
||||
|
||||
#if ENABLED(NEOPIXEL_LED) && DISABLED(MKS_MINI_12864_V3)
|
||||
#if ENABLED(NEOPIXEL_LED) && DISABLED(FYSETC_MINI_12864_2_1)
|
||||
#error "NEOPIXEL_LED (Adafruit NeoPixel) is not supported for HAL/STM32F1. Comment out this line to proceed at your own risk!"
|
||||
#endif
|
||||
|
||||
|
@@ -278,7 +278,7 @@ DSTATUS disk_initialize (
|
||||
if (drv) return STA_NOINIT; // Supports only drive 0
|
||||
sd_power_on(); // Initialize SPI
|
||||
|
||||
if (Stat & STA_NODISK) return Stat; // Is a card existing in the soket?
|
||||
if (Stat & STA_NODISK) return Stat; // Is a card existing in the socket?
|
||||
|
||||
FCLK_SLOW();
|
||||
for (n = 10; n; n--) xchg_spi(0xFF); // Send 80 dummy clocks
|
||||
|
@@ -47,10 +47,7 @@
|
||||
* TODO: Calculate Timer prescale value, so we get the 32bit to adjust
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) {
|
||||
void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority) {
|
||||
nvic_irq_num irq_num;
|
||||
switch (timer_num) {
|
||||
case 1: irq_num = NVIC_TIMER1_CC; break;
|
||||
@@ -73,7 +70,6 @@ void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority)
|
||||
nvic_irq_set_priority(irq_num, priority);
|
||||
}
|
||||
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
/**
|
||||
* Give the Stepper ISR a higher priority (lower number)
|
||||
@@ -81,7 +77,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
*/
|
||||
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
timer_pause(STEP_TIMER_DEV);
|
||||
timer_set_mode(STEP_TIMER_DEV, STEP_TIMER_CHAN, TIMER_OUTPUT_COMPARE); // counter
|
||||
timer_set_count(STEP_TIMER_DEV, 0);
|
||||
@@ -91,11 +87,11 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (STEPPER_TIMER_RATE) / frequency));
|
||||
timer_no_ARR_preload_ARPE(STEP_TIMER_DEV); // Need to be sure no preload on ARR register
|
||||
timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
|
||||
timer_set_interrupt_priority(STEP_TIMER_NUM, STEP_TIMER_IRQ_PRIO);
|
||||
HAL_timer_set_interrupt_priority(MF_TIMER_STEP, STEP_TIMER_IRQ_PRIO);
|
||||
timer_generate_update(STEP_TIMER_DEV);
|
||||
timer_resume(STEP_TIMER_DEV);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_pause(TEMP_TIMER_DEV);
|
||||
timer_set_mode(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, TIMER_OUTPUT_COMPARE);
|
||||
timer_set_count(TEMP_TIMER_DEV, 0);
|
||||
@@ -103,7 +99,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
timer_set_reload(TEMP_TIMER_DEV, 0xFFFF);
|
||||
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, _MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (F_CPU) / (TEMP_TIMER_PRESCALE) / frequency));
|
||||
timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler);
|
||||
timer_set_interrupt_priority(TEMP_TIMER_NUM, TEMP_TIMER_IRQ_PRIO);
|
||||
HAL_timer_set_interrupt_priority(MF_TIMER_TEMP, TEMP_TIMER_IRQ_PRIO);
|
||||
timer_generate_update(TEMP_TIMER_DEV);
|
||||
timer_resume(TEMP_TIMER_DEV);
|
||||
break;
|
||||
@@ -112,31 +108,31 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: ENABLE_STEPPER_DRIVER_INTERRUPT(); break;
|
||||
case TEMP_TIMER_NUM: ENABLE_TEMPERATURE_INTERRUPT(); break;
|
||||
case MF_TIMER_STEP: ENABLE_STEPPER_DRIVER_INTERRUPT(); break;
|
||||
case MF_TIMER_TEMP: ENABLE_TEMPERATURE_INTERRUPT(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: DISABLE_STEPPER_DRIVER_INTERRUPT(); break;
|
||||
case TEMP_TIMER_NUM: DISABLE_TEMPERATURE_INTERRUPT(); break;
|
||||
case MF_TIMER_STEP: DISABLE_STEPPER_DRIVER_INTERRUPT(); break;
|
||||
case MF_TIMER_TEMP: DISABLE_TEMPERATURE_INTERRUPT(); break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) {
|
||||
static inline bool HAL_timer_irq_enabled(const timer_dev * const dev, const uint8_t interrupt) {
|
||||
return bool(*bb_perip(&(dev->regs).gen->DIER, interrupt));
|
||||
}
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM: return timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN);
|
||||
case TEMP_TIMER_NUM: return timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
|
||||
case MF_TIMER_STEP: return HAL_timer_irq_enabled(STEP_TIMER_DEV, STEP_TIMER_CHAN);
|
||||
case MF_TIMER_TEMP: return HAL_timer_irq_enabled(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
timer_dev* get_timer_dev(int number) {
|
||||
timer_dev* HAL_get_timer_dev(int number) {
|
||||
switch (number) {
|
||||
#if STM32_HAVE_TIMER(1)
|
||||
case 1: return &timer1;
|
||||
|
@@ -65,30 +65,30 @@ typedef uint16_t hal_timer_t;
|
||||
* - Otherwise it uses Timer 8 on boards with STM32_HIGH_DENSITY
|
||||
* or Timer 4 on other boards.
|
||||
*/
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_STEP
|
||||
#if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8)
|
||||
#define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
|
||||
#define MF_TIMER_STEP 4 // For C8/CB boards, use timer 4
|
||||
#else
|
||||
#define STEP_TIMER_NUM 5 // for other boards, five is fine.
|
||||
#define MF_TIMER_STEP 5 // for other boards, five is fine.
|
||||
#endif
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 2 // Timer Index for Temperature
|
||||
//#define TEMP_TIMER_NUM 4 // 2->4, Timer 2 for Stepper Current PWM
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 2 // Timer Index for Temperature
|
||||
//#define MF_TIMER_TEMP 4 // 2->4, Timer 2 for Stepper Current PWM
|
||||
#endif
|
||||
|
||||
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE, MKS_ROBIN_E3D, MKS_ROBIN_E3)
|
||||
// SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM.
|
||||
#ifdef STM32_HIGH_DENSITY
|
||||
#define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4
|
||||
#define MF_TIMER_SERVO0 8 // tone.cpp uses Timer 4
|
||||
#else
|
||||
#define SERVO0_TIMER_NUM 3 // tone.cpp uses Timer 8
|
||||
#define MF_TIMER_SERVO0 3 // tone.cpp uses Timer 8
|
||||
#endif
|
||||
#else
|
||||
#define SERVO0_TIMER_NUM 1 // SERVO0 or BLTOUCH
|
||||
#define MF_TIMER_SERVO0 1 // SERVO0 or BLTOUCH
|
||||
#endif
|
||||
|
||||
#define STEP_TIMER_IRQ_PRIO 2
|
||||
@@ -106,14 +106,14 @@ typedef uint16_t hal_timer_t;
|
||||
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
||||
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
|
||||
|
||||
timer_dev* get_timer_dev(int number);
|
||||
#define TIMER_DEV(num) get_timer_dev(num)
|
||||
#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM)
|
||||
#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM)
|
||||
timer_dev* HAL_get_timer_dev(int number);
|
||||
#define TIMER_DEV(num) HAL_get_timer_dev(num)
|
||||
#define STEP_TIMER_DEV TIMER_DEV(MF_TIMER_STEP)
|
||||
#define TEMP_TIMER_DEV TIMER_DEV(MF_TIMER_TEMP)
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
|
||||
|
||||
#define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN)
|
||||
@@ -138,8 +138,8 @@ extern "C" {
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
//static HardwareTimer StepperTimer(STEP_TIMER_NUM);
|
||||
//static HardwareTimer TempTimer(TEMP_TIMER_NUM);
|
||||
//static HardwareTimer StepperTimer(MF_TIMER_STEP);
|
||||
//static HardwareTimer TempTimer(MF_TIMER_TEMP);
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -163,13 +163,13 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
// NOTE: WE have set ARPE = 0, which means the Auto reload register is not preloaded
|
||||
// and there is no need to use any compare, as in the timer mode used, setting ARR to the compare value
|
||||
// will result in exactly the same effect, ie triggering an interrupt, and on top, set counter to 0
|
||||
timer_set_reload(STEP_TIMER_DEV, compare); // We reload direct ARR as needed during counting up
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, compare);
|
||||
break;
|
||||
}
|
||||
@@ -177,18 +177,18 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
|
||||
|
||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case STEP_TIMER_NUM:
|
||||
case MF_TIMER_STEP:
|
||||
// No counter to clear
|
||||
timer_generate_update(STEP_TIMER_DEV);
|
||||
return;
|
||||
case TEMP_TIMER_NUM:
|
||||
case MF_TIMER_TEMP:
|
||||
timer_set_count(TEMP_TIMER_DEV, 0);
|
||||
timer_generate_update(TEMP_TIMER_DEV);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
||||
// No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple.
|
||||
// Needed here to reset ARPE=0 for stepper timer
|
||||
@@ -196,6 +196,6 @@ FORCE_INLINE static void timer_no_ARR_preload_ARPE(timer_dev *dev) {
|
||||
bb_peri_set_bit(&(dev->regs).gen->CR1, TIMER_CR1_ARPE_BIT, 0);
|
||||
}
|
||||
|
||||
void timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority);
|
||||
void HAL_timer_set_interrupt_priority(uint_fast8_t timer_num, uint_fast8_t priority);
|
||||
|
||||
#define TIMER_OC_NO_PRELOAD 0 // Need to disable preload also on compare registers.
|
||||
|
@@ -98,16 +98,14 @@ void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
|
||||
@@ -124,6 +122,12 @@ void HAL_adc_init();
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Pin Map
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
@@ -36,10 +36,9 @@ static SPISettings spiConfig;
|
||||
|
||||
// Initialize SPI bus
|
||||
void spiBegin() {
|
||||
#if !PIN_EXISTS(SD_SS)
|
||||
#error "SD_SS_PIN not defined!"
|
||||
#endif
|
||||
#if PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
#endif
|
||||
SET_OUTPUT(SD_SCK_PIN);
|
||||
SET_INPUT(SD_MISO_PIN);
|
||||
SET_OUTPUT(SD_MOSI_PIN);
|
||||
|
@@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() {
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN;
|
||||
FTM0_SC = 0x00; // Set this to zero before changing the modulus
|
||||
FTM0_CNT = 0x0000; // Reset the count to zero
|
||||
@@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8
|
||||
FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA;
|
||||
break;
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1
|
||||
FTM1_SC = 0x00; // Set this to zero before changing the modulus
|
||||
FTM1_CNT = 0x0000; // Reset the count to zero
|
||||
@@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
|
||||
case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
|
||||
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
|
||||
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
|
||||
case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
|
||||
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
|
||||
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
|
||||
}
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
@@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return NVIC_IS_ENABLED(IRQ_FTM0);
|
||||
case 1: return NVIC_IS_ENABLED(IRQ_FTM1);
|
||||
case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0);
|
||||
case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
FTM0_CNT = 0x0000;
|
||||
FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
break;
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
FTM1_CNT = 0x0000;
|
||||
FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
|
@@ -46,14 +46,14 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000
|
||||
@@ -66,12 +66,12 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() extern "C" void ftm0_isr() //void TC3_Handler()
|
||||
@@ -84,23 +84,23 @@ 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 0: FTM0_C0V = compare; break;
|
||||
case 1: FTM1_C0V = compare; break;
|
||||
case MF_TIMER_STEP: FTM0_C0V = compare; break;
|
||||
case MF_TIMER_TEMP: FTM1_C0V = compare; break;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return FTM0_C0V;
|
||||
case 1: return FTM1_C0V;
|
||||
case MF_TIMER_STEP: return FTM0_C0V;
|
||||
case MF_TIMER_TEMP: return FTM1_C0V;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return FTM0_CNT;
|
||||
case 1: return FTM1_CNT;
|
||||
case MF_TIMER_STEP: return FTM0_CNT;
|
||||
case MF_TIMER_TEMP: return FTM1_CNT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -105,16 +105,14 @@ void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
|
||||
@@ -131,6 +129,12 @@ void HAL_adc_init();
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Pin Map
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
@@ -36,10 +36,9 @@
|
||||
static SPISettings spiConfig;
|
||||
|
||||
void spiBegin() {
|
||||
#if !PIN_EXISTS(SD_SS)
|
||||
#error "SD_SS_PIN not defined!"
|
||||
#endif
|
||||
#if PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
#endif
|
||||
SET_OUTPUT(SD_SCK_PIN);
|
||||
SET_INPUT(SD_MISO_PIN);
|
||||
SET_OUTPUT(SD_MOSI_PIN);
|
||||
|
@@ -47,7 +47,7 @@ FORCE_INLINE static void __DSB() {
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN;
|
||||
FTM0_SC = 0x00; // Set this to zero before changing the modulus
|
||||
FTM0_CNT = 0x0000; // Reset the count to zero
|
||||
@@ -56,7 +56,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
FTM0_SC = (FTM_SC_CLKS(0b1) & FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS) & FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8
|
||||
FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA;
|
||||
break;
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1
|
||||
FTM1_SC = 0x00; // Set this to zero before changing the modulus
|
||||
FTM1_CNT = 0x0000; // Reset the count to zero
|
||||
@@ -70,15 +70,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
|
||||
case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
|
||||
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_FTM0); break;
|
||||
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_FTM1); break;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
|
||||
case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
|
||||
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_FTM0); break;
|
||||
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_FTM1); break;
|
||||
}
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
@@ -89,20 +89,20 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return NVIC_IS_ENABLED(IRQ_FTM0);
|
||||
case 1: return NVIC_IS_ENABLED(IRQ_FTM1);
|
||||
case MF_TIMER_STEP: return NVIC_IS_ENABLED(IRQ_FTM0);
|
||||
case MF_TIMER_TEMP: return NVIC_IS_ENABLED(IRQ_FTM1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
FTM0_CNT = 0x0000;
|
||||
FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
break;
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
FTM1_CNT = 0x0000;
|
||||
FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
|
@@ -45,14 +45,14 @@ typedef uint32_t hal_timer_t;
|
||||
|
||||
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_FREQUENCY 1000
|
||||
@@ -65,12 +65,12 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() extern "C" void ftm0_isr() //void TC3_Handler()
|
||||
@@ -83,23 +83,23 @@ 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 0: FTM0_C0V = compare; break;
|
||||
case 1: FTM1_C0V = compare; break;
|
||||
case MF_TIMER_STEP: FTM0_C0V = compare; break;
|
||||
case MF_TIMER_TEMP: FTM1_C0V = compare; break;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return FTM0_C0V;
|
||||
case 1: return FTM1_C0V;
|
||||
case MF_TIMER_STEP: return FTM0_C0V;
|
||||
case MF_TIMER_TEMP: return FTM1_C0V;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return FTM0_CNT;
|
||||
case 1: return FTM1_CNT;
|
||||
case MF_TIMER_STEP: return FTM0_CNT;
|
||||
case MF_TIMER_TEMP: return FTM1_CNT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -106,17 +106,17 @@ void HAL_adc_init() {
|
||||
void HAL_clear_reset_source() {
|
||||
uint32_t reset_source = SRC_SRSR;
|
||||
SRC_SRSR = reset_source;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
switch (SRC_SRSR & 0xFF) {
|
||||
case 1: return RST_POWER_ON; break;
|
||||
case 2: return RST_SOFTWARE; break;
|
||||
case 4: return RST_EXTERNAL; break;
|
||||
// case 8: return RST_BROWN_OUT; break;
|
||||
//case 8: return RST_BROWN_OUT; break;
|
||||
case 16: return RST_WATCHDOG; break;
|
||||
case 64: return RST_JTAG; break;
|
||||
// case 128: return RST_OVERTEMP; break;
|
||||
//case 128: return RST_OVERTEMP; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ uint16_t HAL_adc_get_result() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_output(uint8_t pin) {
|
||||
bool is_output(pin_t pin) {
|
||||
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||
p = digital_pin_to_info_PGM + pin;
|
||||
return (*(p->reg + 1) & p->mask);
|
||||
|
@@ -125,16 +125,14 @@ void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
extern "C" uint32_t freeMemory();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
|
||||
@@ -152,8 +150,14 @@ void HAL_adc_init();
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Pin Map
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
bool is_output(uint8_t pin);
|
||||
bool is_output(pin_t pin);
|
||||
|
@@ -51,12 +51,9 @@ static SPISettings spiConfig;
|
||||
// ------------------------
|
||||
|
||||
void spiBegin() {
|
||||
#ifndef SD_SS_PIN
|
||||
#error "SD_SS_PIN is not defined!"
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
|
||||
#endif
|
||||
//SET_OUTPUT(SD_SCK_PIN);
|
||||
//SET_INPUT(SD_MISO_PIN);
|
||||
//SET_OUTPUT(SD_MOSI_PIN);
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
case MF_TIMER_STEP:
|
||||
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
|
||||
CCM_CCGR1 |= CCM_CCGR1_GPT1_BUS(CCM_CCGR_ON);
|
||||
|
||||
@@ -48,7 +48,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
attachInterruptVector(IRQ_GPT1, &stepTC_Handler);
|
||||
NVIC_SET_PRIORITY(IRQ_GPT1, 16);
|
||||
break;
|
||||
case 1:
|
||||
case MF_TIMER_TEMP:
|
||||
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
|
||||
CCM_CCGR0 |= CCM_CCGR0_GPT2_BUS(CCM_CCGR_ON);
|
||||
|
||||
@@ -71,19 +71,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
|
||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
NVIC_ENABLE_IRQ(IRQ_GPT1);
|
||||
break;
|
||||
case 1:
|
||||
NVIC_ENABLE_IRQ(IRQ_GPT2);
|
||||
break;
|
||||
case MF_TIMER_STEP: NVIC_ENABLE_IRQ(IRQ_GPT1); break;
|
||||
case MF_TIMER_TEMP: NVIC_ENABLE_IRQ(IRQ_GPT2); break;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
|
||||
case 1: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
|
||||
case MF_TIMER_STEP: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
|
||||
case MF_TIMER_TEMP: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
|
||||
}
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
@@ -93,20 +89,16 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return (NVIC_IS_ENABLED(IRQ_GPT1));
|
||||
case 1: return (NVIC_IS_ENABLED(IRQ_GPT2));
|
||||
case MF_TIMER_STEP: return (NVIC_IS_ENABLED(IRQ_GPT1));
|
||||
case MF_TIMER_TEMP: return (NVIC_IS_ENABLED(IRQ_GPT2));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0:
|
||||
GPT1_SR = GPT_IR_OF1IE; // clear OF3 bit
|
||||
break;
|
||||
case 1:
|
||||
GPT2_SR = GPT_IR_OF1IE; // clear OF3 bit
|
||||
break;
|
||||
case MF_TIMER_STEP: GPT1_SR = GPT_IR_OF1IE; break; // clear OF3 bit
|
||||
case MF_TIMER_TEMP: GPT2_SR = GPT_IR_OF1IE; break; // clear OF3 bit
|
||||
}
|
||||
asm volatile("dsb");
|
||||
}
|
||||
|
@@ -43,14 +43,14 @@ typedef uint32_t hal_timer_t;
|
||||
#define GPT1_TIMER_RATE (GPT_TIMER_RATE / GPT1_TIMER_PRESCALE) // 75MHz
|
||||
#define GPT2_TIMER_RATE (GPT_TIMER_RATE / GPT2_TIMER_PRESCALE) // 15MHz
|
||||
|
||||
#ifndef STEP_TIMER_NUM
|
||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||
#ifndef MF_TIMER_STEP
|
||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
||||
#endif
|
||||
#ifndef PULSE_TIMER_NUM
|
||||
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||
#ifndef MF_TIMER_PULSE
|
||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
||||
#endif
|
||||
#ifndef TEMP_TIMER_NUM
|
||||
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||
#ifndef MF_TIMER_TEMP
|
||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
||||
#endif
|
||||
|
||||
#define TEMP_TIMER_RATE 1000000
|
||||
@@ -64,12 +64,12 @@ typedef uint32_t hal_timer_t;
|
||||
#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(STEP_TIMER_NUM)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||
#define ENABLE_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(TEMP_TIMER_NUM)
|
||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||
#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() extern "C" void stepTC_Handler() // GPT1_Handler()
|
||||
@@ -87,27 +87,23 @@ 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 0:
|
||||
GPT1_OCR1 = compare - 1;
|
||||
break;
|
||||
case 1:
|
||||
GPT2_OCR1 = compare - 1;
|
||||
break;
|
||||
case MF_TIMER_STEP: GPT1_OCR1 = compare - 1; break;
|
||||
case MF_TIMER_TEMP: GPT2_OCR1 = compare - 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return GPT1_OCR1;
|
||||
case 1: return GPT2_OCR1;
|
||||
case MF_TIMER_STEP: return GPT1_OCR1;
|
||||
case MF_TIMER_TEMP: return GPT2_OCR1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||
switch (timer_num) {
|
||||
case 0: return GPT1_CNT;
|
||||
case 1: return GPT2_CNT;
|
||||
case MF_TIMER_STEP: return GPT1_CNT;
|
||||
case MF_TIMER_TEMP: return GPT2_CNT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -118,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
//void HAL_timer_isr_epilogue(const uint8_t timer_num) {}
|
||||
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
|
@@ -108,13 +108,14 @@
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
void dump_delay_accuracy_check() {
|
||||
auto report_call_time = [](PGM_P const name, PGM_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
|
||||
auto report_call_time = [](FSTR_P const name, FSTR_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
|
||||
SERIAL_ECHOPGM("Calling ");
|
||||
SERIAL_ECHOPGM_P(name);
|
||||
SERIAL_ECHOF(name);
|
||||
SERIAL_ECHOLNPGM(" for ", cycles);
|
||||
SERIAL_ECHOPGM_P(unit);
|
||||
SERIAL_ECHOF(unit);
|
||||
SERIAL_ECHOLNPGM(" took: ", total);
|
||||
SERIAL_ECHOPGM_P(unit);
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOF(unit);
|
||||
if (do_flush) SERIAL_FLUSHTX();
|
||||
};
|
||||
|
||||
@@ -126,41 +127,42 @@
|
||||
constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 };
|
||||
for (auto i : testValues) {
|
||||
s = micros(); DELAY_US(i); e = micros();
|
||||
report_call_time(PSTR("delay"), PSTR("us"), i, e - s);
|
||||
report_call_time(F("delay"), F("us"), i, e - s);
|
||||
}
|
||||
|
||||
if (HW_REG(_DWT_CTRL)) {
|
||||
static FSTR_P cyc = F("cycles");
|
||||
static FSTR_P dcd = F("DELAY_CYCLES directly ");
|
||||
|
||||
for (auto i : testValues) {
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(PSTR("runtime delay"), PSTR("cycles"), i, e - s);
|
||||
report_call_time(F("runtime delay"), cyc, i, e - s);
|
||||
}
|
||||
|
||||
// Measure the delay to call a real function compared to a function pointer
|
||||
s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(PSTR("delay_dwt"), PSTR("cycles"), 1, e - s);
|
||||
|
||||
static PGMSTR(dcd, "DELAY_CYCLES directly ");
|
||||
report_call_time(F("delay_dwt"), cyc, 1, e - s);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 1, e - s, false);
|
||||
report_call_time(dcd, cyc, 1, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 5, e - s, false);
|
||||
report_call_time(dcd, cyc, 5, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 10, e - s, false);
|
||||
report_call_time(dcd, cyc, 10, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 20, e - s, false);
|
||||
report_call_time(dcd, cyc, 20, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 50, e - s, false);
|
||||
report_call_time(dcd, cyc, 50, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 100, e - s, false);
|
||||
report_call_time(dcd, cyc, 100, e - s, false);
|
||||
|
||||
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT);
|
||||
report_call_time(dcd, PSTR("cycles"), 200, e - s, false);
|
||||
report_call_time(dcd, cyc, 200, e - s, false);
|
||||
}
|
||||
}
|
||||
#endif // MARLIN_DEV_MODE
|
||||
@@ -170,7 +172,7 @@
|
||||
|
||||
void calibrate_delay_loop() {}
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
void dump_delay_accuracy_check() { SERIAL_ECHOPGM_P(PSTR("N/A on this platform")); }
|
||||
void dump_delay_accuracy_check() { SERIAL_ECHOPGM("N/A on this platform"); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -92,6 +92,12 @@ void calibrate_delay_loop();
|
||||
|
||||
#define DELAY_CYCLES(X) do { SmartDelay<IS_CONSTEXPR(X), IS_CONSTEXPR(X) ? X : 0> _smrtdly_X(X); } while(0)
|
||||
|
||||
#if GCC_VERSION <= 70000
|
||||
#define DELAY_CYCLES_VAR(X) DelayCycleFnc(X)
|
||||
#else
|
||||
#define DELAY_CYCLES_VAR DELAY_CYCLES
|
||||
#endif
|
||||
|
||||
// For delay in microseconds, no smart delay selection is required, directly call the delay function
|
||||
// Teensy compiler is too old and does not accept smart delay compile-time / run-time selection correctly
|
||||
#define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL))
|
||||
@@ -200,9 +206,12 @@ void calibrate_delay_loop();
|
||||
#endif
|
||||
|
||||
#if ENABLED(DELAY_NS_ROUND_DOWN)
|
||||
#define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL) // floor
|
||||
#define _NS_TO_CYCLES(x) ( (x) * ((F_CPU) / 1000000UL) / 1000UL) // floor
|
||||
#elif ENABLED(DELAY_NS_ROUND_CLOSEST)
|
||||
#define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 500) / 1000UL) // round
|
||||
#define _NS_TO_CYCLES(x) (((x) * ((F_CPU) / 1000000UL) + 500) / 1000UL) // round
|
||||
#else
|
||||
#define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 999) / 1000UL) // "ceil"
|
||||
#define _NS_TO_CYCLES(x) (((x) * ((F_CPU) / 1000000UL) + 999) / 1000UL) // "ceil"
|
||||
#endif
|
||||
|
||||
#define DELAY_NS(x) DELAY_CYCLES(_NS_TO_CYCLES(x))
|
||||
#define DELAY_NS_VAR(x) DELAY_CYCLES_VAR(_NS_TO_CYCLES(x))
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#define DISABLED(V...) DO(DIS,&&,V)
|
||||
|
||||
#undef _BV
|
||||
#define _BV(b) (1UL << (b))
|
||||
#define _BV(b) (1 << (b))
|
||||
#ifndef SBI
|
||||
#define SBI(A,B) (A |= _BV(B))
|
||||
#endif
|
||||
@@ -83,7 +83,14 @@
|
||||
#endif
|
||||
|
||||
#ifndef FORCE_INLINE
|
||||
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#endif
|
||||
|
||||
#include "progmem.h"
|
||||
|
||||
class __FlashStringHelper;
|
||||
typedef const __FlashStringHelper* FSTR_P;
|
||||
#ifndef FPSTR
|
||||
#define FPSTR(S) (reinterpret_cast<FSTR_P>(S))
|
||||
#endif
|
||||
#define FTOP(S) (reinterpret_cast<const char*>(S))
|
||||
|
@@ -41,7 +41,7 @@
|
||||
#define START_FLASH_ADDR 0x00000000
|
||||
#define END_FLASH_ADDR 0x00080000
|
||||
|
||||
#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx)
|
||||
#elif defined(__STM32F1__) || defined(STM32F1xx) || defined(STM32F0xx) || defined(STM32G0xx)
|
||||
|
||||
// For STM32F103ZET6/STM32F103VET6/STM32F0xx
|
||||
// SRAM (0x20000000 - 0x20010000) (64kb)
|
||||
|
@@ -101,7 +101,7 @@ struct __attribute__((packed)) ContextSavedFrame {
|
||||
uint32_t ELR;
|
||||
};
|
||||
|
||||
#if DISABLED(STM32F0xx)
|
||||
#if NONE(STM32F0xx, STM32G0xx)
|
||||
extern "C"
|
||||
__attribute__((naked)) void CommonHandler_ASM() {
|
||||
__asm__ __volatile__ (
|
||||
|
@@ -38,7 +38,8 @@
|
||||
#define PSTR(str) (str)
|
||||
#endif
|
||||
#ifndef F
|
||||
#define F(str) (str)
|
||||
class __FlashStringHelper;
|
||||
#define F(str) (reinterpret_cast<const __FlashStringHelper *>(PSTR(str)))
|
||||
#endif
|
||||
#ifndef _SFR_BYTE
|
||||
#define _SFR_BYTE(n) (n)
|
||||
@@ -110,7 +111,7 @@
|
||||
#define strrchr_P(str, c) strrchr((str), (c))
|
||||
#endif
|
||||
#ifndef strsep_P
|
||||
#define strsep_P(strp, delim) strsep((strp), (delim))
|
||||
#define strsep_P(pstr, delim) strsep((pstr), (delim))
|
||||
#endif
|
||||
#ifndef strspn_P
|
||||
#define strspn_P(str, chrs) strspn((str), (chrs))
|
||||
|
@@ -212,10 +212,18 @@
|
||||
|
||||
#include "module/tool_change.h"
|
||||
|
||||
#if HAS_FANCHECK
|
||||
#include "feature/fancheck.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_CONTROLLER_FAN)
|
||||
#include "feature/controllerfan.h"
|
||||
#endif
|
||||
|
||||
#if HAS_PRUSA_MMU1
|
||||
#include "feature/mmu/mmu.h"
|
||||
#endif
|
||||
|
||||
#if HAS_PRUSA_MMU2
|
||||
#include "feature/mmu/mmu2.h"
|
||||
#endif
|
||||
@@ -240,6 +248,10 @@
|
||||
#include "feature/power.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EASYTHREED_UI)
|
||||
#include "feature/easythreed_ui.h"
|
||||
#endif
|
||||
|
||||
PGMSTR(M112_KILL_STR, "M112 Shutdown");
|
||||
|
||||
MarlinState marlin_state = MF_INITIALIZING;
|
||||
@@ -357,14 +369,14 @@ void startOrResumeJob() {
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
||||
|
||||
#ifdef EVENT_GCODE_SD_ABORT
|
||||
queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
|
||||
queue.inject(F(EVENT_GCODE_SD_ABORT));
|
||||
#endif
|
||||
|
||||
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
|
||||
}
|
||||
|
||||
inline void finishSDPrinting() {
|
||||
if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued
|
||||
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
|
||||
marlin_state = MF_RUNNING; // Signal to stop trying
|
||||
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
||||
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
|
||||
@@ -474,7 +486,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed
|
||||
if (ELAPSED(ms, next_home_key_ms)) {
|
||||
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
|
||||
LCD_MESSAGEPGM(MSG_AUTO_HOME);
|
||||
LCD_MESSAGE(MSG_AUTO_HOME);
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
}
|
||||
@@ -493,14 +505,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
if (ELAPSED(ms, next_cub_ms_##N)) { \
|
||||
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
|
||||
CODE; \
|
||||
queue.inject_P(PSTR(BUTTON##N##_GCODE)); \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_LCD_MENU, ui.quick_feedback()); \
|
||||
} \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
|
||||
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)))
|
||||
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGE_F(BUTTON##N##_DESC))
|
||||
|
||||
#if HAS_BETTER_USER_BUTTON(1)
|
||||
CHECK_BETTER_USER_BUTTON(1);
|
||||
@@ -629,6 +641,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TERN_(EASYTHREED_UI, easythreed_ui.run());
|
||||
|
||||
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
|
||||
|
||||
TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
|
||||
@@ -770,7 +784,10 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
(void)check_tool_sensor_stats(active_extruder, true);
|
||||
|
||||
// Handle filament runout sensors
|
||||
TERN_(HAS_FILAMENT_SENSOR, runout.run());
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled()))
|
||||
runout.run();
|
||||
#endif
|
||||
|
||||
// Run HAL idle tasks
|
||||
TERN_(HAL_IDLETASK, HAL_idletask());
|
||||
@@ -825,6 +842,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#if HAS_AUTO_REPORTING
|
||||
if (!gcode.autoreport_paused) {
|
||||
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
|
||||
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
|
||||
@@ -852,16 +870,16 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
* Kill all activity and lock the machine.
|
||||
* After this the machine will need to be reset.
|
||||
*/
|
||||
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
||||
void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
||||
thermalManager.disable_all_heaters();
|
||||
|
||||
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
|
||||
|
||||
// Echo the LCD message to serial for extra context
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); }
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR));
|
||||
#else
|
||||
UNUSED(lcd_error); UNUSED(lcd_component);
|
||||
#endif
|
||||
@@ -872,7 +890,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
|
||||
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
||||
|
||||
#ifdef ACTION_ON_KILL
|
||||
host_action_kill();
|
||||
hostui.kill();
|
||||
#endif
|
||||
|
||||
minkill(steppers_off);
|
||||
@@ -935,7 +953,7 @@ void stop() {
|
||||
|
||||
if (!IsStopped()) {
|
||||
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
|
||||
LCD_MESSAGEPGM(MSG_STOPPED);
|
||||
LCD_MESSAGE(MSG_STOPPED);
|
||||
safe_delay(350); // allow enough time for messages to get out before stopping
|
||||
marlin_state = MF_STOPPED;
|
||||
}
|
||||
@@ -1100,6 +1118,10 @@ void setup() {
|
||||
|
||||
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = HAL_get_reset_source();
|
||||
HAL_clear_reset_source();
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
auto log_current_ms = [&](PGM_P const msg) {
|
||||
SERIAL_ECHO_START();
|
||||
@@ -1228,15 +1250,14 @@ void setup() {
|
||||
|
||||
SETUP_RUN(esp_wifi_init());
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = HAL_get_reset_source();
|
||||
// Report Reset Reason
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
||||
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
HAL_clear_reset_source();
|
||||
|
||||
// Identify myself as Marlin x.x.x
|
||||
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
|
||||
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
|
||||
SERIAL_ECHO_MSG(
|
||||
@@ -1268,6 +1289,8 @@ void setup() {
|
||||
SETUP_RUN(controllerFan.setup());
|
||||
#endif
|
||||
|
||||
TERN_(HAS_FANCHECK, fan_check.init());
|
||||
|
||||
// UI must be initialized before EEPROM
|
||||
// (because EEPROM code calls the UI).
|
||||
|
||||
@@ -1346,6 +1369,9 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#if PIN_EXISTS(PROBE_ENABLE)
|
||||
OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable
|
||||
#endif
|
||||
SETUP_RUN(endstops.enable_z_probe(false));
|
||||
#endif
|
||||
|
||||
@@ -1521,11 +1547,11 @@ void setup() {
|
||||
|
||||
#ifdef STARTUP_COMMANDS
|
||||
SETUP_LOG("STARTUP_COMMANDS");
|
||||
queue.inject_P(PSTR(STARTUP_COMMANDS));
|
||||
queue.inject(F(STARTUP_COMMANDS));
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
SETUP_RUN(host_action_prompt_end());
|
||||
SETUP_RUN(hostui.prompt_end());
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
@@ -1547,15 +1573,15 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
SETUP_LOG("E3V2 Init");
|
||||
Encoder_Configuration();
|
||||
HMI_Init();
|
||||
HMI_SetLanguageCache();
|
||||
HMI_StartFrame(true);
|
||||
DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG));
|
||||
#endif
|
||||
|
||||
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
|
||||
ui.reset_status(true); // Show service messages or keep current status
|
||||
SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
|
||||
#endif
|
||||
|
||||
#if ENABLED(MAX7219_DEBUG)
|
||||
@@ -1586,7 +1612,11 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
||||
ui.check_touch_calibration();
|
||||
SETUP_RUN(ui.check_touch_calibration());
|
||||
#endif
|
||||
|
||||
#if ENABLED(EASYTHREED_UI)
|
||||
SETUP_RUN(easythreed_ui.init());
|
||||
#endif
|
||||
|
||||
marlin_state = MF_RUNNING;
|
||||
|
@@ -38,7 +38,7 @@ inline void idle_no_sleep() { idle(true); }
|
||||
extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed
|
||||
#endif
|
||||
|
||||
void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
|
||||
void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false);
|
||||
void minkill(const bool steppers_off=false);
|
||||
|
||||
// Global State of the firmware
|
||||
|
@@ -324,37 +324,41 @@
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 4027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 4028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 4029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
#define BOARD_JGAURORA_A5S_A1 4030 // JGAurora A5S A1 (STM32F103ZET6)
|
||||
#define BOARD_FYSETC_AIO_II 4031 // FYSETC AIO_II
|
||||
#define BOARD_FYSETC_CHEETAH 4032 // FYSETC Cheetah
|
||||
#define BOARD_FYSETC_CHEETAH_V12 4033 // FYSETC Cheetah V1.2
|
||||
#define BOARD_LONGER3D_LK 4034 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
|
||||
#define BOARD_CCROBOT_MEEB_3DP 4035 // ccrobot-online.com MEEB_3DP (STM32F103RC)
|
||||
#define BOARD_CHITU3D_V5 4036 // Chitu3D TronXY X5SA V5 Board
|
||||
#define BOARD_CHITU3D_V6 4037 // Chitu3D TronXY X5SA V6 Board
|
||||
#define BOARD_CHITU3D_V9 4038 // Chitu3D TronXY X5SA V9 Board
|
||||
#define BOARD_CREALITY_V4 4039 // Creality v4.x (STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 4040 // Creality v4.2.7 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V4210 4041 // Creality v4.2.10 (STM32F103RE) as found in the CR-30
|
||||
#define BOARD_CREALITY_V431 4042 // Creality v4.3.1 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_A 4043 // Creality v4.3.1a (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_B 4044 // Creality v4.3.1b (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_C 4045 // Creality v4.3.1c (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_D 4046 // Creality v4.3.1d (STM32F103RE)
|
||||
#define BOARD_CREALITY_V452 4047 // Creality v4.5.2 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V453 4048 // Creality v4.5.3 (STM32F103RE)
|
||||
#define BOARD_TRIGORILLA_PRO 4049 // Trigorilla Pro (STM32F103ZET6)
|
||||
#define BOARD_FLY_MINI 4050 // FLYmaker FLY MINI (STM32F103RCT6)
|
||||
#define BOARD_FLSUN_HISPEED 4051 // FLSUN HiSpeedV1 (STM32F103VET6)
|
||||
#define BOARD_BEAST 4052 // STM32F103RET6 Libmaple-based controller
|
||||
#define BOARD_MINGDA_MPX_ARM_MINI 4053 // STM32F103ZET6 Mingda MD-16
|
||||
#define BOARD_GTM32_PRO_VD 4054 // STM32F103VET6 controller
|
||||
#define BOARD_ZONESTAR_ZM3E2 4055 // Zonestar ZM3E2 (STM32F103RCT6)
|
||||
#define BOARD_ZONESTAR_ZM3E4 4056 // Zonestar ZM3E4 V1 (STM32F103VCT6)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 4057 // Zonestar ZM3E4 V2 (STM32F103VCT6)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V3_0 4027 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 4028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
#define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZET6)
|
||||
#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II
|
||||
#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah
|
||||
#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2
|
||||
#define BOARD_LONGER3D_LK 4035 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
|
||||
#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC)
|
||||
#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board
|
||||
#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board
|
||||
#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board
|
||||
#define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RE)
|
||||
#define BOARD_CREALITY_V423 4041 // Creality v4.2.3 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 4042 // Creality v4.2.7 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V4210 4043 // Creality v4.2.10 (STM32F103RE) as found in the CR-30
|
||||
#define BOARD_CREALITY_V431 4044 // Creality v4.3.1 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_A 4045 // Creality v4.3.1a (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_B 4046 // Creality v4.3.1b (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_C 4047 // Creality v4.3.1c (STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_D 4048 // Creality v4.3.1d (STM32F103RE)
|
||||
#define BOARD_CREALITY_V452 4049 // Creality v4.5.2 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V453 4050 // Creality v4.5.3 (STM32F103RE)
|
||||
#define BOARD_CREALITY_V24S1 4051 // Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7
|
||||
#define BOARD_TRIGORILLA_PRO 4052 // Trigorilla Pro (STM32F103ZET6)
|
||||
#define BOARD_FLY_MINI 4053 // FLYmaker FLY MINI (STM32F103RCT6)
|
||||
#define BOARD_FLSUN_HISPEED 4054 // FLSUN HiSpeedV1 (STM32F103VET6)
|
||||
#define BOARD_BEAST 4055 // STM32F103RET6 Libmaple-based controller
|
||||
#define BOARD_MINGDA_MPX_ARM_MINI 4056 // STM32F103ZET6 Mingda MD-16
|
||||
#define BOARD_GTM32_PRO_VD 4057 // STM32F103VET6 controller
|
||||
#define BOARD_ZONESTAR_ZM3E2 4058 // Zonestar ZM3E2 (STM32F103RCT6)
|
||||
#define BOARD_ZONESTAR_ZM3E4 4059 // Zonestar ZM3E4 V1 (STM32F103VCT6)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 4060 // Zonestar ZM3E4 V2 (STM32F103VCT6)
|
||||
#define BOARD_ERYONE_ERY32_MINI 4061 // Eryone Ery32 mini (STM32F103VET6)
|
||||
|
||||
//
|
||||
// ARM Cortex-M4F
|
||||
@@ -380,28 +384,32 @@
|
||||
#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VGT6)
|
||||
#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VGT6)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VGT6)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6/STM32F429VGT6)
|
||||
#define BOARD_BTT_GTR_V1_0 4214 // BigTreeTech GTR v1.0 (STM32F407IGT)
|
||||
#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZET6)
|
||||
#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZET6)
|
||||
#define BOARD_LERDGE_K 4217 // Lerdge K (STM32F407ZG)
|
||||
#define BOARD_LERDGE_S 4218 // Lerdge S (STM32F407VE)
|
||||
#define BOARD_LERDGE_X 4219 // Lerdge X (STM32F407VE)
|
||||
#define BOARD_VAKE403D 4220 // VAkE 403D (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6 4221 // FYSETC S6 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6_V2_0 4222 // FYSETC S6 v2.0 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_SPIDER 4223 // FYSETC Spider (STM32F446VET6)
|
||||
#define BOARD_FLYF407ZG 4224 // FLYmaker FLYF407ZG (STM32F407ZG)
|
||||
#define BOARD_MKS_ROBIN2 4225 // MKS_ROBIN2 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 4226 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 4227 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_MKS_MONSTER8 4228 // MKS Monster8 (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4 4229 // ANET ET4 V1.x (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4P 4230 // ANET ET4P V1.x (STM32F407VGT6)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4231 // FYSETC Cheetah V2.0
|
||||
#define BOARD_TH3D_EZBOARD_LITE_V2 4232 // TH3D EZBoard Lite v2.0
|
||||
#define BOARD_INDEX_REV03 4233 // Index PnP Controller REV03 (STM32F407VET6/VGT6)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4234 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VET6)
|
||||
#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZET6/STM32F429ZGT6)
|
||||
#define BOARD_LERDGE_K 4218 // Lerdge K (STM32F407ZG)
|
||||
#define BOARD_LERDGE_S 4219 // Lerdge S (STM32F407VE)
|
||||
#define BOARD_LERDGE_X 4220 // Lerdge X (STM32F407VE)
|
||||
#define BOARD_VAKE403D 4221 // VAkE 403D (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VET6)
|
||||
#define BOARD_FLYF407ZG 4225 // FLYmaker FLYF407ZG (STM32F407ZG)
|
||||
#define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_MKS_MONSTER8 4229 // MKS Monster8 (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VGT6)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0
|
||||
#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0
|
||||
#define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VET6/VGT6)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VET6)
|
||||
#define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VET6)
|
||||
#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RCT6)
|
||||
#define BOARD_FYSETC_SPIDER_V2_2 4238 // FYSETC Spider V2.2 (STM32F446VET6)
|
||||
|
||||
//
|
||||
// ARM Cortex M7
|
||||
@@ -421,7 +429,11 @@
|
||||
#define BOARD_MRR_ESPA 6001 // MRR ESPA based on ESP32 (native pins only)
|
||||
#define BOARD_MRR_ESPE 6002 // MRR ESPE based on ESP32 (with I2S stepper stream)
|
||||
#define BOARD_E4D_BOX 6003 // E4d@BOX
|
||||
#define BOARD_FYSETC_E4 6004 // FYSETC E4
|
||||
#define BOARD_RESP32_CUSTOM 6004 // Rutilea ESP32 custom board
|
||||
#define BOARD_FYSETC_E4 6005 // FYSETC E4
|
||||
#define BOARD_PANDA_ZHU 6006 // Panda_ZHU
|
||||
#define BOARD_PANDA_M4 6007 // Panda_M4
|
||||
#define BOARD_MKS_TINYBEE 6008 // MKS TinyBee based on ESP32 (with I2S stepper stream)
|
||||
|
||||
//
|
||||
// SAMD51 ARM Cortex M4
|
||||
|
@@ -36,6 +36,8 @@
|
||||
#undef DEBUG_ECHOLN
|
||||
#undef DEBUG_ECHOPGM
|
||||
#undef DEBUG_ECHOLNPGM
|
||||
#undef DEBUG_ECHOF
|
||||
#undef DEBUG_ECHOLNF
|
||||
#undef DEBUG_ECHOPGM_P
|
||||
#undef DEBUG_ECHOLNPGM_P
|
||||
#undef DEBUG_ECHOPAIR_F
|
||||
@@ -54,7 +56,7 @@
|
||||
#if DEBUG_OUT
|
||||
|
||||
#include "debug_section.h"
|
||||
#define DEBUG_SECTION(N,S,D) SectionLog N(PSTR(S),D)
|
||||
#define DEBUG_SECTION(N,S,D) SectionLog N(F(S),D)
|
||||
|
||||
#define DEBUG_ECHO_START SERIAL_ECHO_START
|
||||
#define DEBUG_ERROR_START SERIAL_ERROR_START
|
||||
@@ -65,6 +67,8 @@
|
||||
#define DEBUG_ECHOLN SERIAL_ECHOLN
|
||||
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
|
||||
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
|
||||
#define DEBUG_ECHOF SERIAL_ECHOF
|
||||
#define DEBUG_ECHOLNF SERIAL_ECHOLNF
|
||||
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
|
||||
#define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P
|
||||
#define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F
|
||||
@@ -94,6 +98,8 @@
|
||||
#define DEBUG_ECHOLN(...) NOOP
|
||||
#define DEBUG_ECHOPGM(...) NOOP
|
||||
#define DEBUG_ECHOLNPGM(...) NOOP
|
||||
#define DEBUG_ECHOF(...) NOOP
|
||||
#define DEBUG_ECHOLNF(...) NOOP
|
||||
#define DEBUG_ECHOPGM_P(...) NOOP
|
||||
#define DEBUG_ECHOLNPGM_P(...) NOOP
|
||||
#define DEBUG_ECHOPAIR_F(...) NOOP
|
||||
|
@@ -26,22 +26,22 @@
|
||||
|
||||
class SectionLog {
|
||||
public:
|
||||
SectionLog(PGM_P const msg=nullptr, bool inbug=true) {
|
||||
the_msg = msg;
|
||||
if ((debug = inbug)) echo_msg(PSTR(">>>"));
|
||||
SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) {
|
||||
the_msg = fmsg;
|
||||
if ((debug = inbug)) echo_msg(F(">>>"));
|
||||
}
|
||||
|
||||
~SectionLog() { if (debug) echo_msg(PSTR("<<<")); }
|
||||
~SectionLog() { if (debug) echo_msg(F("<<<")); }
|
||||
|
||||
private:
|
||||
PGM_P the_msg;
|
||||
FSTR_P the_msg;
|
||||
bool debug;
|
||||
|
||||
void echo_msg(PGM_P const pre) {
|
||||
SERIAL_ECHOPGM_P(pre);
|
||||
void echo_msg(FSTR_P const fpre) {
|
||||
SERIAL_ECHOF(fpre);
|
||||
if (the_msg) {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOPGM_P(the_msg);
|
||||
SERIAL_ECHOF(the_msg);
|
||||
}
|
||||
SERIAL_CHAR(' ');
|
||||
print_pos(current_position);
|
||||
|
@@ -140,6 +140,7 @@
|
||||
#define STR_RESEND "Resend: "
|
||||
#define STR_UNKNOWN_COMMAND "Unknown command: \""
|
||||
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
|
||||
#define STR_ERR_FANSPEED "Fan speed E"
|
||||
|
||||
#define STR_PROBE_OFFSET "Probe Offset"
|
||||
#define STR_SKEW_MIN "min_skew_factor: "
|
||||
|
@@ -33,6 +33,12 @@
|
||||
|
||||
#define _AXIS(A) (A##_AXIS)
|
||||
|
||||
#define _XSTOP_ 0x01
|
||||
#define _YSTOP_ 0x02
|
||||
#define _ZSTOP_ 0x03
|
||||
#define _ISTOP_ 0x04
|
||||
#define _JSTOP_ 0x05
|
||||
#define _KSTOP_ 0x06
|
||||
#define _XMIN_ 0x11
|
||||
#define _YMIN_ 0x12
|
||||
#define _ZMIN_ 0x13
|
||||
@@ -160,7 +166,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
// Macros to chain up to 14 conditions
|
||||
// Macros to chain up to 40 conditions
|
||||
#define _DO_1(W,C,A) (_##W##_1(A))
|
||||
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
|
||||
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
|
||||
@@ -176,6 +182,31 @@
|
||||
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
|
||||
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
|
||||
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
|
||||
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
|
||||
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
|
||||
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
|
||||
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
|
||||
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
|
||||
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
|
||||
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
|
||||
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
|
||||
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
|
||||
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
|
||||
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
|
||||
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
|
||||
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
|
||||
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
|
||||
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
|
||||
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
|
||||
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
|
||||
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
|
||||
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
|
||||
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
|
||||
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
|
||||
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
|
||||
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
|
||||
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
|
||||
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
|
||||
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
|
||||
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
|
||||
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
|
||||
@@ -251,6 +282,11 @@
|
||||
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
|
||||
}while(0)
|
||||
|
||||
#define CODE_16( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O; P
|
||||
#define CODE_15( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O
|
||||
#define CODE_14( A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N
|
||||
#define CODE_13( A,B,C,D,E,F,G,H,I,J,K,L,M,...) A; B; C; D; E; F; G; H; I; J; K; L; M
|
||||
#define CODE_12( A,B,C,D,E,F,G,H,I,J,K,L,...) A; B; C; D; E; F; G; H; I; J; K; L
|
||||
#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
|
||||
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
|
||||
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
|
||||
|
@@ -69,23 +69,23 @@ PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR
|
||||
|
||||
#endif
|
||||
|
||||
void serialprintPGM(PGM_P str) {
|
||||
void serial_print_P(PGM_P str) {
|
||||
while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
|
||||
}
|
||||
|
||||
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); }
|
||||
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); }
|
||||
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); }
|
||||
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); }
|
||||
|
||||
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
||||
|
||||
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=nullptr*/) {
|
||||
if (pre) serialprintPGM(pre);
|
||||
serialprintPGM(onoff ? on : off);
|
||||
if (post) serialprintPGM(post);
|
||||
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
|
||||
if (pre) serial_print(pre);
|
||||
serial_print(onoff ? on : off);
|
||||
if (post) serial_print(post);
|
||||
}
|
||||
void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(STR_ON) : PSTR(STR_OFF)); }
|
||||
void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
|
||||
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
|
||||
void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
|
||||
void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
|
||||
|
||||
void print_bin(uint16_t val) {
|
||||
for (uint8_t i = 16; i--;) {
|
||||
@@ -94,10 +94,10 @@ void print_bin(uint16_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
|
||||
if (prefix) serialprintPGM(prefix);
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
|
||||
if (prefix) serial_print(prefix);
|
||||
SERIAL_ECHOPGM_P(
|
||||
LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k)
|
||||
);
|
||||
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
|
||||
if (suffix) serial_print(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ extern uint8_t marlin_debug_flags;
|
||||
// interface with the ability to output to multiple serial ports.
|
||||
#if HAS_MULTI_SERIAL
|
||||
#define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p)
|
||||
#define _PORT_RESTORE(n,p) RESTORE(n)
|
||||
#define _PORT_RESTORE(n) RESTORE(n)
|
||||
#define SERIAL_ASSERT(P) if (multiSerial.portMask!=(P)) { debugger(); }
|
||||
// If we have a catchall, use that directly
|
||||
#ifdef SERIAL_CATCHALL
|
||||
@@ -167,13 +167,10 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
|
||||
#define AS_CHAR(C) serial_char_t(C)
|
||||
#define AS_DIGIT(C) AS_CHAR('0' + (C))
|
||||
|
||||
// SERIAL_ECHO_F prints a floating point value with optional precision
|
||||
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
|
||||
|
||||
template <typename T>
|
||||
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
|
||||
|
||||
// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed
|
||||
// SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base
|
||||
template <typename T, typename U>
|
||||
void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
|
||||
|
||||
@@ -184,8 +181,20 @@ void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); }
|
||||
inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); }
|
||||
inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
|
||||
|
||||
// Print a single PROGMEM string to serial
|
||||
void serialprintPGM(PGM_P str);
|
||||
// Serial echo and error prefixes
|
||||
#define SERIAL_ECHO_START() serial_echo_start()
|
||||
#define SERIAL_ERROR_START() serial_error_start()
|
||||
|
||||
// Serial end-of-line
|
||||
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
||||
|
||||
// Print a single PROGMEM, PGM_P, or PSTR() string.
|
||||
void serial_print_P(PGM_P str);
|
||||
inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); }
|
||||
|
||||
// Print a single FSTR_P, F(), or FPSTR() string.
|
||||
inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); }
|
||||
inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); }
|
||||
|
||||
//
|
||||
// SERIAL_ECHOPGM... macros are used to output string-value pairs.
|
||||
@@ -195,8 +204,8 @@ void serialprintPGM(PGM_P str);
|
||||
#define __SEP_N(N,V...) _SEP_##N(V)
|
||||
#define _SEP_N(N,V...) __SEP_N(N,V)
|
||||
#define _SEP_N_REF() _SEP_N
|
||||
#define _SEP_1(s) serialprintPGM(PSTR(s));
|
||||
#define _SEP_2(s,v) serial_echopair_PGM(PSTR(s),v);
|
||||
#define _SEP_1(s) serial_print(F(s));
|
||||
#define _SEP_2(s,v) serial_echopair(F(s),v);
|
||||
#define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
@@ -204,8 +213,8 @@ void serialprintPGM(PGM_P str);
|
||||
#define __SELP_N(N,V...) _SELP_##N(V)
|
||||
#define _SELP_N(N,V...) __SELP_N(N,V)
|
||||
#define _SELP_N_REF() _SELP_N
|
||||
#define _SELP_1(s) serialprintPGM(PSTR(s "\n"));
|
||||
#define _SELP_2(s,v) serial_echopair_PGM(PSTR(s),v); SERIAL_EOL();
|
||||
#define _SELP_1(s) serial_print(F(s "\n"));
|
||||
#define _SELP_2(s,v) serial_echolnpair(F(s),v);
|
||||
#define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
@@ -213,8 +222,8 @@ void serialprintPGM(PGM_P str);
|
||||
#define __SEP_N_P(N,V...) _SEP_##N##_P(V)
|
||||
#define _SEP_N_P(N,V...) __SEP_N_P(N,V)
|
||||
#define _SEP_N_P_REF() _SEP_N_P
|
||||
#define _SEP_1_P(p) serialprintPGM(p);
|
||||
#define _SEP_2_P(p,v) serial_echopair_PGM(p,v);
|
||||
#define _SEP_1_P(p) serial_print_P(p);
|
||||
#define _SEP_2_P(p,v) serial_echopair_P(p,v);
|
||||
#define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
@@ -222,11 +231,29 @@ void serialprintPGM(PGM_P str);
|
||||
#define __SELP_N_P(N,V...) _SELP_##N##_P(V)
|
||||
#define _SELP_N_P(N,V...) __SELP_N_P(N,V)
|
||||
#define _SELP_N_P_REF() _SELP_N_P
|
||||
#define _SELP_1_P(p) { serialprintPGM(p); SERIAL_EOL(); }
|
||||
#define _SELP_2_P(p,v) { serial_echopair_PGM(p,v); SERIAL_EOL(); }
|
||||
#define _SELP_1_P(p) serial_println_P(p)
|
||||
#define _SELP_2_P(p,v) serial_echolnpair_P(p,v)
|
||||
#define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
|
||||
#define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR().
|
||||
#define __SEP_N_F(N,V...) _SEP_##N##_F(V)
|
||||
#define _SEP_N_F(N,V...) __SEP_N_F(N,V)
|
||||
#define _SEP_N_F_REF() _SEP_N_F
|
||||
#define _SEP_1_F(p) serial_print(p);
|
||||
#define _SEP_2_F(p,v) serial_echopair(p,v);
|
||||
#define _SEP_3_F(p,v,V...) _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOF(V...) do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR().
|
||||
#define __SELP_N_F(N,V...) _SELP_##N##_F(V)
|
||||
#define _SELP_N_F(N,V...) __SELP_N_F(N,V)
|
||||
#define _SELP_N_F_REF() _SELP_N_F
|
||||
#define _SELP_1_F(p) serial_println(p)
|
||||
#define _SELP_2_F(p,v) serial_echolnpair(p,v)
|
||||
#define _SELP_3_F(p,v,V...) { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); }
|
||||
#define SERIAL_ECHOLNF(V...) do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
#ifdef AllowDifferentTypeInList
|
||||
|
||||
inline void SERIAL_ECHOLIST_IMPL() {}
|
||||
@@ -236,47 +263,49 @@ void serialprintPGM(PGM_P str);
|
||||
template <typename T, typename ... Args>
|
||||
void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
|
||||
SERIAL_IMPL.print(t);
|
||||
serialprintPGM(PSTR(", "));
|
||||
serial_print(F(", "));
|
||||
SERIAL_ECHOLIST_IMPL(args...);
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
|
||||
SERIAL_IMPL.print(str);
|
||||
void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) {
|
||||
SERIAL_IMPL.print(FTOP(str));
|
||||
SERIAL_ECHOLIST_IMPL(args...);
|
||||
}
|
||||
|
||||
#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
|
||||
|
||||
template <typename ... Args>
|
||||
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
|
||||
serialprintPGM(str);
|
||||
void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) {
|
||||
serial_print(fstr);
|
||||
typename Private::first_type_of<Args...>::type values[] = { args... };
|
||||
constexpr size_t argsSize = sizeof...(args);
|
||||
for (size_t i = 0; i < argsSize; i++) {
|
||||
if (i) serialprintPGM(PSTR(", "));
|
||||
if (i) serial_print(F(", "));
|
||||
SERIAL_IMPL.print(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serialprintPGM(P); SERIAL_ECHO_F(V); }while(0)
|
||||
#define SERIAL_ECHOLNPAIR_F_P(V...) do{ SERIAL_ECHOPAIR_F_P(V); SERIAL_EOL(); }while(0)
|
||||
// SERIAL_ECHO_F prints a floating point value with optional precision
|
||||
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
|
||||
|
||||
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_P(PSTR(S),V)
|
||||
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0)
|
||||
#define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHOPAIR_F_F(S,V...) do{ serial_print(S); SERIAL_ECHO_F(V); }while(0)
|
||||
#define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_F(F(S),V)
|
||||
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHO_START() serial_echo_start()
|
||||
#define SERIAL_ERROR_START() serial_error_start()
|
||||
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
||||
|
||||
#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
|
||||
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
|
||||
|
||||
#define SERIAL_ECHO_SP(C) serial_spaces(C)
|
||||
|
||||
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST))
|
||||
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST))
|
||||
|
||||
#if SERIAL_FLOAT_PRECISION
|
||||
#define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION)
|
||||
@@ -287,33 +316,42 @@ void serialprintPGM(PGM_P str);
|
||||
//
|
||||
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
|
||||
//
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); }
|
||||
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, float v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, double v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
|
||||
//inline void serial_echopair_P(PGM_P const pstr, const char *v) { serial_print_P(pstr); SERIAL_ECHO(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, FSTR_P v) { serial_print_P(pstr); SERIAL_ECHOF(v); }
|
||||
|
||||
// Default implementation for types without a specialization. Handles integers.
|
||||
template <typename T>
|
||||
void serial_echopair_PGM(PGM_P const s_P, T v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); }
|
||||
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
|
||||
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); }
|
||||
// Add a newline.
|
||||
template <typename T>
|
||||
inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); }
|
||||
|
||||
// Catch-all for __FlashStringHelper *
|
||||
template <typename T>
|
||||
inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); }
|
||||
|
||||
// Add a newline to the serial output
|
||||
template <typename T>
|
||||
inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); }
|
||||
|
||||
void serial_echo_start();
|
||||
void serial_error_start();
|
||||
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr);
|
||||
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
|
||||
void serialprint_onoff(const bool onoff);
|
||||
void serialprintln_onoff(const bool onoff);
|
||||
void serialprint_truefalse(const bool tf);
|
||||
void serial_spaces(uint8_t count);
|
||||
|
||||
void print_bin(const uint16_t val);
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
|
||||
|
||||
inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
|
||||
inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
|
||||
print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
|
||||
}
|
||||
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0)
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)
|
||||
|
@@ -26,13 +26,6 @@
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
class __FlashStringHelper;
|
||||
typedef const __FlashStringHelper* FSTR_P;
|
||||
#ifndef FPSTR
|
||||
#define FPSTR(S) (reinterpret_cast<FSTR_P>(S))
|
||||
#endif
|
||||
#define FTOP(S) (reinterpret_cast<const char*>(S))
|
||||
|
||||
//
|
||||
// Conditional type assignment magic. For example...
|
||||
//
|
||||
@@ -89,7 +82,7 @@ enum AxisEnum : uint8_t {
|
||||
#undef _EN_ITEM
|
||||
|
||||
// Core also keeps toolhead directions
|
||||
#if EITHER(IS_CORE, MARKFORGED_XY)
|
||||
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
|
||||
, X_HEAD, Y_HEAD, Z_HEAD
|
||||
#endif
|
||||
|
||||
|
@@ -60,7 +60,8 @@ void safe_delay(millis_t ms) {
|
||||
TERN_(DELTA, "Delta")
|
||||
TERN_(IS_SCARA, "SCARA")
|
||||
TERN_(IS_CORE, "Core")
|
||||
TERN_(MARKFORGED_XY, "MarkForged")
|
||||
TERN_(MARKFORGED_XY, "MarkForgedXY")
|
||||
TERN_(MARKFORGED_YX, "MarkForgedYX")
|
||||
TERN_(IS_CARTESIAN, "Cartesian")
|
||||
);
|
||||
|
||||
@@ -92,9 +93,9 @@ void safe_delay(millis_t ms) {
|
||||
SERIAL_ECHOPGM(" (Aligned With");
|
||||
|
||||
if (probe.offset_xy.y > 0)
|
||||
SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Distal") : PSTR("-Back"));
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
|
||||
else if (probe.offset_xy.y < 0)
|
||||
SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Proximal") : PSTR("-Front"));
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
|
||||
else if (probe.offset_xy.x != 0)
|
||||
SERIAL_ECHOPGM("-Center");
|
||||
|
||||
@@ -102,7 +103,7 @@ void safe_delay(millis_t ms) {
|
||||
|
||||
#endif
|
||||
|
||||
SERIAL_ECHOPGM_P(probe.offset.z < 0 ? PSTR("Below") : probe.offset.z > 0 ? PSTR("Above") : PSTR("Same Z as"));
|
||||
SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
|
||||
SERIAL_ECHOLNPGM(" Nozzle)");
|
||||
|
||||
#endif
|
||||
|
104
Marlin/src/feature/adc/adc_mcp3426.cpp
Normal file
104
Marlin/src/feature/adc/adc_mcp3426.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* adc_mcp3426.cpp - library for MicroChip MCP3426 I2C A/D converter
|
||||
*
|
||||
* For implementation details, please take a look at the datasheet:
|
||||
* https://www.microchip.com/en-us/product/MCP3426
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAS_MCP3426_ADC)
|
||||
|
||||
#include "adc_mcp3426.h"
|
||||
|
||||
// Read the ADC value from MCP342X on a specific channel
|
||||
int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) {
|
||||
Error = false;
|
||||
|
||||
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
||||
Wire.setSDA(pin_t(I2C_SDA_PIN));
|
||||
Wire.setSCL(pin_t(I2C_SCL_PIN));
|
||||
#endif
|
||||
|
||||
Wire.begin(); // No address joins the BUS as the master
|
||||
|
||||
Wire.beginTransmission(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS));
|
||||
|
||||
// Continuous Conversion Mode, 16 bit, Channel 1, Gain x4
|
||||
// 26 = 0b00011000
|
||||
// RXXCSSGG
|
||||
// R = Ready Bit
|
||||
// XX = Channel (00=1, 01=2, 10=3 (MCP3428), 11=4 (MCP3428))
|
||||
// C = Conversion Mode Bit (1= Continuous Conversion Mode (Default))
|
||||
// SS = Sample rate, 10=15 samples per second @ 16 bits
|
||||
// GG = Gain 00 =x1
|
||||
uint8_t controlRegister = 0b00011000;
|
||||
|
||||
if (channel == 2) controlRegister |= 0b00100000; // Select channel 2
|
||||
|
||||
if (gain == 2)
|
||||
controlRegister |= 0b00000001;
|
||||
else if (gain == 4)
|
||||
controlRegister |= 0b00000010;
|
||||
else if (gain == 8)
|
||||
controlRegister |= 0b00000011;
|
||||
|
||||
Wire.write(controlRegister);
|
||||
if (Wire.endTransmission() != 0) {
|
||||
Error = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t len = 3;
|
||||
uint8_t buffer[len] = {};
|
||||
|
||||
do {
|
||||
Wire.requestFrom(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS), len);
|
||||
if (Wire.available() != len) {
|
||||
Error = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < len; ++i)
|
||||
buffer[i] = Wire.read();
|
||||
|
||||
// Is conversion ready, if not loop around again
|
||||
} while ((buffer[2] & 0x80) != 0);
|
||||
|
||||
union TwoBytesToInt16 {
|
||||
uint8_t bytes[2];
|
||||
int16_t integervalue;
|
||||
};
|
||||
TwoBytesToInt16 ConversionUnion;
|
||||
|
||||
ConversionUnion.bytes[1] = buffer[0];
|
||||
ConversionUnion.bytes[0] = buffer[1];
|
||||
|
||||
return ConversionUnion.integervalue;
|
||||
}
|
||||
|
||||
MCP3426 mcp3426;
|
||||
|
||||
#endif // HAS_MCP3426_ADC
|
41
Marlin/src/feature/adc/adc_mcp3426.h
Normal file
41
Marlin/src/feature/adc/adc_mcp3426.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Arduino library for MicroChip MCP3426 I2C A/D converter.
|
||||
* https://www.microchip.com/en-us/product/MCP3426
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// Address of MCP342X chip
|
||||
#define MCP342X_ADC_I2C_ADDRESS 104
|
||||
|
||||
class MCP3426 {
|
||||
public:
|
||||
int16_t ReadValue(uint8_t channel, uint8_t gain);
|
||||
bool Error;
|
||||
};
|
||||
|
||||
extern MCP3426 mcp3426;
|
@@ -64,7 +64,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
static axis_bits_t last_direction_bits;
|
||||
axis_bits_t changed_dir = last_direction_bits ^ dm;
|
||||
// Ignore direction change unless steps are taken in that direction
|
||||
#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
|
||||
#if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX)
|
||||
if (!da) CBI(changed_dir, X_AXIS);
|
||||
if (!db) CBI(changed_dir, Y_AXIS);
|
||||
if (!dc) CBI(changed_dir, Z_AXIS);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user