Compare commits
210 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04acb12148 | |||
| cfe5bf2929 | |||
| a131edd6ff | |||
| ed60c3c68b | |||
| 4051eae885 | |||
| 0a07bba213 | |||
| 2f4f2bce15 | |||
| 0d87dd9d51 | |||
| e11a5ee717 | |||
| e8c0363051 | |||
| 2d6454b352 | |||
| 28548efa75 | |||
| da0bef50e1 | |||
| b954959f55 | |||
| 434bf81f8e | |||
| 82d3d78e31 | |||
| fb4d465360 | |||
| 3827ceaf66 | |||
| 6ba08130f0 | |||
| 78f871567f | |||
| 9e30173b13 | |||
| f0bd400002 | |||
| 0fa3d2642a | |||
| 4cf4647c9a | |||
| 5766dc0ece | |||
| 01990f2bf4 | |||
| d74ee8ccc4 | |||
| 953b6844ca | |||
| e6ccf3b72b | |||
| d9229ff355 | |||
| ee35929b61 | |||
| 07b979012a | |||
| 126e78dcce | |||
| e02de3a256 | |||
| 97a7c2160e | |||
| caf5d5b134 | |||
| 05a46084b6 | |||
| e676d833a3 | |||
| 73a0f33767 | |||
| e787c8f26b | |||
| 147dcaf600 | |||
| dd3bf2995b | |||
| 142177426b | |||
| 072b90d105 | |||
| efba06c4ce | |||
| 2cc35a9ad1 | |||
| b748506230 | |||
| c3a4ef77af | |||
| 86c1fde309 | |||
| 89def456e8 | |||
| 0518737119 | |||
| 12b3f18bb2 | |||
| 4d0c6841f8 | |||
| 99c3a7136d | |||
| cd3997f045 | |||
| 479074ccba | |||
| a21fc27056 | |||
| 485fbf2040 | |||
| 09a519bfb5 | |||
| 81ef02e41f | |||
| 0226692e6b | |||
| 0cd1d9c3c9 | |||
| ab7137ab8e | |||
| 84113367fc | |||
| c24ecfb6f0 | |||
| 442f0baf14 | |||
| 40aab1e298 | |||
| 09fbe372da | |||
| 279a393e81 | |||
| 1e2e0c3a36 | |||
| 86f03cf57a | |||
| 7f598ae66d | |||
| 0a598071af | |||
| 861dd33fa1 | |||
| ac14c65643 | |||
| 0f7fb5d88d | |||
| 428f721cbf | |||
| 31bc23b6e3 | |||
| a1ba166740 | |||
| 88829bd92d | |||
| 7e0208940b | |||
| 12d491c5f7 | |||
| 29635232d3 | |||
| 4e72b17a88 | |||
| 8b8c862615 | |||
| 45ca25a4ab | |||
| 8f35e9a797 | |||
| b4688346ab | |||
| e0c60a83a2 | |||
| b7358449e0 | |||
| 85ebd170a9 | |||
| 70cdfbe8fc | |||
| 5dc55150bd | |||
| ef34fd1a3f | |||
| 854cfc016d | |||
| b7f628ce2f | |||
| f54ec92ba8 | |||
| 2e142725a6 | |||
| 6eca4bbab1 | |||
| de7ac7f594 | |||
| 28c591309f | |||
| 55add905cb | |||
| 8d7ecad531 | |||
| a7d79618b9 | |||
| acd825972c | |||
| 7eee772f60 | |||
| 63bc413da8 | |||
| 22977c885b | |||
| de76f2f21a | |||
| d57feeadaf | |||
| 36623a2382 | |||
| 83278bdc17 | |||
| 30697cb53f | |||
| 4eb8a87193 | |||
| d2814c7aa7 | |||
| 6f71a14150 | |||
| 1067950697 | |||
| 7b7add3843 | |||
| 05e67a9262 | |||
| c4ef2d63e1 | |||
| 2a137d6744 | |||
| c0becd6ce1 | |||
| d5dfd18c24 | |||
| dcc10565f8 | |||
| 4c388d7118 | |||
| 94ca5487ab | |||
| a23212bd95 | |||
| a748eaade7 | |||
| ba88365364 | |||
| 8d9db0f899 | |||
| 23bc810e6e | |||
| 7ad4de2c08 | |||
| d21e1d4dc8 | |||
| 8b7cfa0429 | |||
| 906dcc7536 | |||
| 061e026384 | |||
| 5d591fd91d | |||
| 854da5fd9e | |||
| 7e45d56e66 | |||
| 71ce7803e7 | |||
| c5bf705717 | |||
| e82b4e98a4 | |||
| c271a89a4f | |||
| ea993a657f | |||
| 5813488412 | |||
| a365163ff0 | |||
| 4668b27158 | |||
| e733e50207 | |||
| 5549d07da3 | |||
| 257ffe98b1 | |||
| 2ed5937daf | |||
| 00c28eb9e3 | |||
| 63a7d42f30 | |||
| 94bd6d52e9 | |||
| 9cbab467b4 | |||
| db7828504e | |||
| 4797f25428 | |||
| 6bd541d730 | |||
| 3591eb5d5d | |||
| 22182d9a98 | |||
| 1f61b743a6 | |||
| f071274493 | |||
| 2a4a89d8cb | |||
| a9f44e37a9 | |||
| af05b6e482 | |||
| 2b39e51a40 | |||
| 37f490fdd0 | |||
| c57f715d00 | |||
| 580c99ece2 | |||
| eaab2dea92 | |||
| a7bd35b993 | |||
| 8d864d797a | |||
| 61649aa3c0 | |||
| 220cd5a640 | |||
| 72f2657a0e | |||
| fb61a50e21 | |||
| 21257f7e21 | |||
| 8df61893c3 | |||
| 095f060c24 | |||
| f5a5d7a620 | |||
| fabc2002ed | |||
| 3f264942cb | |||
| 3810986dba | |||
| 5951e646d0 | |||
| d4c34205b5 | |||
| c6bbed7cdb | |||
| a531c01889 | |||
| 0f0e239264 | |||
| fa55caed1f | |||
| bf98c16a00 | |||
| 72603b627a | |||
| 284d07d4d8 | |||
| 09a290cc61 | |||
| 25b9bb35ab | |||
| 9e96b89856 | |||
| 92efc33ace | |||
| 81bad7b124 | |||
| 1df97254cb | |||
| aa80cb0620 | |||
| 4b6109f4e7 | |||
| 70c3060769 | |||
| 472f1ece2a | |||
| f6c58c59c3 | |||
| e6099fd83f | |||
| fd622e9b01 | |||
| d2373b847a | |||
| b10f7181e0 | |||
| 5455499945 | |||
| 17feb1640e | |||
| fed71986c8 |
@@ -113,7 +113,7 @@ jobs:
|
||||
- BTT_GTR_V1_0
|
||||
- BTT_SKR_PRO
|
||||
- FLYF407ZG
|
||||
- FYSETC_S6
|
||||
- STM32F446VE_fysetc
|
||||
- LERDGEK
|
||||
- LERDGEX
|
||||
- mks_robin_pro2
|
||||
@@ -188,6 +188,7 @@ jobs:
|
||||
|
||||
- name: Install Simulator dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential
|
||||
sudo apt-get install libsdl2-dev
|
||||
sudo apt-get install libsdl2-net-dev
|
||||
|
||||
+67
-46
@@ -129,6 +129,7 @@
|
||||
|
||||
// Name displayed in the LCD "Ready" message and Info menu
|
||||
//#define CUSTOM_MACHINE_NAME "3D Printer"
|
||||
//#define CONFIGURABLE_MACHINE_NAME // Add G-code M550 to set/report the machine name
|
||||
|
||||
// Printer's unique ID, used by some programs to differentiate between machines.
|
||||
// Choose your own or use a service like https://www.uuidgenerator.net/version4
|
||||
@@ -586,7 +587,7 @@
|
||||
#define DUMMY_THERMISTOR_998_VALUE 25
|
||||
#define DUMMY_THERMISTOR_999_VALUE 100
|
||||
|
||||
// Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1
|
||||
// Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 / 2 / BED
|
||||
#if TEMP_SENSOR_IS_MAX_TC(0)
|
||||
#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000)
|
||||
#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000
|
||||
@@ -599,6 +600,10 @@
|
||||
#define MAX31865_SENSOR_OHMS_2 100
|
||||
#define MAX31865_CALIBRATION_OHMS_2 430
|
||||
#endif
|
||||
#if TEMP_SENSOR_IS_MAX_TC(BED)
|
||||
#define MAX31865_SENSOR_OHMS_BED 100
|
||||
#define MAX31865_CALIBRATION_OHMS_BED 430
|
||||
#endif
|
||||
|
||||
#if HAS_E_TEMP_SENSOR
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
|
||||
@@ -691,6 +696,7 @@
|
||||
#define PID_K1 0.95 // Smoothing factor within any PID loop
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
//#define MIN_POWER 0
|
||||
//#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation.
|
||||
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
|
||||
// Set/get with G-code: M301 E[extruder number, 0-2]
|
||||
@@ -1507,7 +1513,6 @@
|
||||
* For information about this sensor https://github.com/bigtreetech/MicroProbe
|
||||
*
|
||||
* Also requires PROBE_ENABLE_DISABLE
|
||||
* With FT_MOTION requires ENDSTOP_INTERRUPTS_FEATURE
|
||||
*/
|
||||
//#define BIQU_MICROPROBE_V1 // Triggers HIGH
|
||||
//#define BIQU_MICROPROBE_V2 // Triggers LOW
|
||||
@@ -1646,15 +1651,15 @@
|
||||
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
|
||||
#define PROBING_MARGIN 10
|
||||
|
||||
// X and Y axis travel speed (mm/min) between probes.
|
||||
// X and Y axis travel speed between probes.
|
||||
// Leave undefined to use the average of the current XY homing feedrate.
|
||||
#define XY_PROBE_FEEDRATE (133*60)
|
||||
#define XY_PROBE_FEEDRATE (133*60) // (mm/min)
|
||||
|
||||
// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2)
|
||||
#define Z_PROBE_FEEDRATE_FAST (4*60)
|
||||
// Feedrate for the first approach when double-probing (MULTIPLE_PROBING == 2)
|
||||
#define Z_PROBE_FEEDRATE_FAST (4*60) // (mm/min)
|
||||
|
||||
// Feedrate (mm/min) for the "accurate" probe of each point
|
||||
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2)
|
||||
// Feedrate for the "accurate" probe of each point
|
||||
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2) // (mm/min)
|
||||
|
||||
/**
|
||||
* Probe Activation Switch
|
||||
@@ -1771,17 +1776,17 @@
|
||||
// @section stepper drivers
|
||||
|
||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||
// :{ 0:'Low', 1:'High' }
|
||||
#define X_ENABLE_ON 0
|
||||
#define Y_ENABLE_ON 0
|
||||
#define Z_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0 // For all extruders
|
||||
//#define I_ENABLE_ON 0
|
||||
//#define J_ENABLE_ON 0
|
||||
//#define K_ENABLE_ON 0
|
||||
//#define U_ENABLE_ON 0
|
||||
//#define V_ENABLE_ON 0
|
||||
//#define W_ENABLE_ON 0
|
||||
// :['LOW', 'HIGH']
|
||||
#define X_ENABLE_ON LOW
|
||||
#define Y_ENABLE_ON LOW
|
||||
#define Z_ENABLE_ON LOW
|
||||
#define E_ENABLE_ON LOW // For all extruders
|
||||
//#define I_ENABLE_ON LOW
|
||||
//#define J_ENABLE_ON LOW
|
||||
//#define K_ENABLE_ON LOW
|
||||
//#define U_ENABLE_ON LOW
|
||||
//#define V_ENABLE_ON LOW
|
||||
//#define W_ENABLE_ON LOW
|
||||
|
||||
// Disable axis steppers immediately when they're not being stepped.
|
||||
// WARNING: When motors turn off there is a chance of losing position accuracy!
|
||||
@@ -2104,6 +2109,12 @@
|
||||
//#define AUTO_BED_LEVELING_UBL
|
||||
//#define MESH_BED_LEVELING
|
||||
|
||||
/**
|
||||
* Commands to execute at the start of G29 probing,
|
||||
* after switching to the PROBING_TOOL.
|
||||
*/
|
||||
//#define EVENT_GCODE_BEFORE_G29 "M300 P440 S200"
|
||||
|
||||
/**
|
||||
* Commands to execute at the end of G29 probing.
|
||||
* Useful to retract or move the Z probe out of the way.
|
||||
@@ -2888,13 +2899,15 @@
|
||||
//
|
||||
//#define MAKEBOARD_MINI_2_LINE_DISPLAY_1602
|
||||
|
||||
//
|
||||
// ANET and Tronxy 20x4 Controller
|
||||
//
|
||||
//#define ZONESTAR_LCD // Requires ADC_KEYPAD_PIN to be assigned to an analog pin.
|
||||
// This LCD is known to be susceptible to electrical interference
|
||||
// which scrambles the display. Pressing any button clears it up.
|
||||
// This is a LCD2004 display with 5 analog buttons.
|
||||
/**
|
||||
* ANET and Tronxy 20x4 Controller
|
||||
* LCD2004 display with 5 analog buttons.
|
||||
*
|
||||
* NOTE: Requires ADC_KEYPAD_PIN to be assigned to an analog pin.
|
||||
* This LCD is known to be susceptible to electrical interference which
|
||||
* scrambles the display. Press any button to clear it up.
|
||||
*/
|
||||
//#define ZONESTAR_LCD
|
||||
|
||||
//
|
||||
// Generic 16x2, 16x4, 20x2, or 20x4 character-based LCD.
|
||||
@@ -3171,14 +3184,14 @@
|
||||
//
|
||||
// Tiny, but very sharp OLED display
|
||||
//
|
||||
//#define MKS_12864OLED // Uses the SH1106 controller (default)
|
||||
//#define MKS_12864OLED // Uses the SH1106 controller
|
||||
//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
|
||||
|
||||
//
|
||||
// Zonestar OLED 128×64 Full Graphics Controller
|
||||
//
|
||||
//#define ZONESTAR_12864LCD // Graphical (DOGM) with ST7920 controller
|
||||
//#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller (default)
|
||||
//#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller
|
||||
//#define ZONESTAR_12864OLED_SSD1306 // 0.96" OLED with SSD1306 controller
|
||||
|
||||
//
|
||||
@@ -3427,7 +3440,7 @@
|
||||
|
||||
#if ENABLED(TFT_COLOR_UI)
|
||||
/**
|
||||
* TFT Font for Color_UI. Choose one of the following:
|
||||
* TFT Font for Color UI. Choose one of the following:
|
||||
*
|
||||
* NOTOSANS - Default font with anti-aliasing. Supports Latin Extended and non-Latin characters.
|
||||
* UNIFONT - Lightweight font, no anti-aliasing. Supports Latin Extended and non-Latin characters.
|
||||
@@ -3436,7 +3449,7 @@
|
||||
#define TFT_FONT NOTOSANS
|
||||
|
||||
/**
|
||||
* TFT Theme for Color_UI. Choose one of the following or add a new one to 'Marlin/src/lcd/tft/themes' directory
|
||||
* TFT Theme for Color UI. Choose one of the following or add a new one to 'Marlin/src/lcd/tft/themes' directory
|
||||
*
|
||||
* BLUE_MARLIN - Default theme with 'midnight blue' background
|
||||
* BLACK_MARLIN - Theme with 'black' background
|
||||
@@ -3512,7 +3525,9 @@
|
||||
// https://reprapworld.com/products/electronics/ramps/keypad_v1_0_fully_assembled/
|
||||
//
|
||||
//#define REPRAPWORLD_KEYPAD
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
|
||||
#endif
|
||||
|
||||
//
|
||||
// EasyThreeD ET-4000+ with button input and status LED
|
||||
@@ -3529,22 +3544,26 @@
|
||||
// :[1,2,3,4,5,6,7,8]
|
||||
//#define NUM_M106_FANS 1
|
||||
|
||||
// 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.
|
||||
/**
|
||||
* Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
|
||||
* which is not as annoying as with the hardware PWM. On the other hand, if this frequency
|
||||
* is too low, you should also increment SOFT_PWM_SCALE.
|
||||
*/
|
||||
//#define FAN_SOFT_PWM
|
||||
|
||||
// Incrementing this by 1 will double the software PWM frequency,
|
||||
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
|
||||
// However, control resolution will be halved for each increment;
|
||||
// at zero value, there are 128 effective control positions.
|
||||
// :[0,1,2,3,4,5,6,7]
|
||||
/**
|
||||
* Incrementing this by 1 will double the software PWM frequency, affecting heaters, and
|
||||
* the fan if FAN_SOFT_PWM is enabled. However, control resolution will be halved for each
|
||||
* increment; at zero value, there are 128 effective control positions.
|
||||
* :[0,1,2,3,4,5,6,7]
|
||||
*/
|
||||
#define SOFT_PWM_SCALE 0
|
||||
|
||||
// If SOFT_PWM_SCALE is set to a value higher than 0, dithering can
|
||||
// be used to mitigate the associated resolution loss. If enabled,
|
||||
// some of the PWM cycles are stretched so on average the desired
|
||||
// duty cycle is attained.
|
||||
/**
|
||||
* If SOFT_PWM_SCALE is set to a value higher than 0, dithering can be used to mitigate the
|
||||
* associated resolution loss. If enabled, some of the PWM cycles are stretched so on average
|
||||
* the desired duty cycle is attained.
|
||||
*/
|
||||
//#define SOFT_PWM_DITHER
|
||||
|
||||
// @section extras
|
||||
@@ -3554,9 +3573,11 @@
|
||||
|
||||
// @section lights
|
||||
|
||||
// Temperature status LEDs that display the hotend and bed temperature.
|
||||
// If all hotends, bed temperature, and target temperature are under 54C
|
||||
// then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
|
||||
/**
|
||||
* Temperature status LEDs that display the hotend and bed temperature.
|
||||
* If all hotends, bed temperature, and target temperature are under 54C
|
||||
* the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
|
||||
*/
|
||||
//#define TEMP_STAT_LEDS
|
||||
|
||||
// Support for BlinkM/CyzRgb
|
||||
|
||||
+61
-50
@@ -174,9 +174,10 @@
|
||||
* Thermocouple Options — for MAX6675 (-2), MAX31855 (-3), and MAX31865 (-5).
|
||||
*/
|
||||
//#define TEMP_SENSOR_FORCE_HW_SPI // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus.
|
||||
//#define MAX31865_SENSOR_WIRES_0 2 // (2-4) Number of wires for the probe connected to a MAX31865 board.
|
||||
//#define MAX31865_SENSOR_WIRES_1 2
|
||||
//#define MAX31865_SENSOR_WIRES_2 2
|
||||
//#define MAX31865_SENSOR_WIRES_0 2 // (2-4) Number of wires for the probe connected to a MAX31865 board.
|
||||
//#define MAX31865_SENSOR_WIRES_1 2
|
||||
//#define MAX31865_SENSOR_WIRES_2 2
|
||||
//#define MAX31865_SENSOR_WIRES_BED 2
|
||||
|
||||
//#define MAX31865_50HZ_FILTER // Use a 50Hz filter instead of the default 60Hz.
|
||||
//#define MAX31865_USE_READ_ERROR_DETECTION // Treat value spikes (20°C delta in under 1s) as read errors.
|
||||
@@ -188,6 +189,7 @@
|
||||
//#define MAX31865_WIRE_OHMS_0 0.95f // For 2-wire, set the wire resistances for more accurate readings.
|
||||
//#define MAX31865_WIRE_OHMS_1 0.0f
|
||||
//#define MAX31865_WIRE_OHMS_2 0.0f
|
||||
//#define MAX31865_WIRE_OHMS_BED 0.0f
|
||||
|
||||
/**
|
||||
* Hephestos 2 24V heated bed upgrade kit.
|
||||
@@ -211,18 +213,19 @@
|
||||
//
|
||||
// Heated Chamber options
|
||||
//
|
||||
#if DISABLED(PIDTEMPCHAMBER)
|
||||
#define CHAMBER_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control
|
||||
#if ENABLED(CHAMBER_LIMIT_SWITCHING)
|
||||
#define CHAMBER_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > CHAMBER_HYSTERESIS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_CHAMBER
|
||||
//#define HEATER_CHAMBER_PIN P2_04 // Required heater on/off pin (example: SKR 1.4 Turbo HE1 plug)
|
||||
//#define HEATER_CHAMBER_INVERTING false
|
||||
//#define FAN1_PIN -1 // Remove the fan signal on pin P2_04 (example: SKR 1.4 Turbo HE1 plug)
|
||||
|
||||
#if DISABLED(PIDTEMPCHAMBER)
|
||||
#define CHAMBER_CHECK_INTERVAL 5000 // (ms) Interval between checks in bang-bang control
|
||||
#if ENABLED(CHAMBER_LIMIT_SWITCHING)
|
||||
#define CHAMBER_HYSTERESIS 2 // (°C) Only set the relevant heater state when ABS(T-target) > CHAMBER_HYSTERESIS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//#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)
|
||||
@@ -1019,7 +1022,7 @@
|
||||
|
||||
#endif // BLTOUCH
|
||||
|
||||
// @section calibration
|
||||
// @section calibrate
|
||||
|
||||
/**
|
||||
* Z Steppers Auto-Alignment
|
||||
@@ -1416,24 +1419,24 @@
|
||||
#define MICROSTEP_MODES { 16, 16, 16, 16, 16, 16 } // [1,2,4,8,16]
|
||||
|
||||
/**
|
||||
* @section stepper motor current
|
||||
* @section stepper motor current
|
||||
*
|
||||
* Some boards have a means of setting the stepper motor current via firmware.
|
||||
* Some boards have a means of setting the stepper motor current via firmware.
|
||||
*
|
||||
* The power on motor currents are set by:
|
||||
* PWM_MOTOR_CURRENT - used by MINIRAMBO & ULTIMAIN_2
|
||||
* known compatible chips: A4982
|
||||
* DIGIPOT_MOTOR_CURRENT - used by BQ_ZUM_MEGA_3D, RAMBO & SCOOVO_X9H
|
||||
* known compatible chips: AD5206
|
||||
* DAC_MOTOR_CURRENT_DEFAULT - used by PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||
* known compatible chips: MCP4728
|
||||
* DIGIPOT_I2C_MOTOR_CURRENTS - used by 5DPRINT, AZTEEG_X3_PRO, AZTEEG_X5_MINI_WIFI, MIGHTYBOARD_REVE
|
||||
* known compatible chips: MCP4451, MCP4018
|
||||
* The power on motor currents are set by:
|
||||
* PWM_MOTOR_CURRENT - used by MINIRAMBO & ULTIMAIN_2
|
||||
* known compatible chips: A4982
|
||||
* DIGIPOT_MOTOR_CURRENT - used by BQ_ZUM_MEGA_3D, RAMBO & SCOOVO_X9H
|
||||
* known compatible chips: AD5206
|
||||
* DAC_MOTOR_CURRENT_DEFAULT - used by PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||
* known compatible chips: MCP4728
|
||||
* DIGIPOT_I2C_MOTOR_CURRENTS - used by 5DPRINT, AZTEEG_X3_PRO, AZTEEG_X5_MINI_WIFI, MIGHTYBOARD_REVE
|
||||
* known compatible chips: MCP4451, MCP4018
|
||||
*
|
||||
* Motor currents can also be set by M907 - M910 and by the LCD.
|
||||
* M907 - applies to all.
|
||||
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
|
||||
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||
* Motor currents can also be set by M907 - M910 and by the LCD.
|
||||
* M907 - applies to all.
|
||||
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
|
||||
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||
*/
|
||||
//#define PWM_MOTOR_CURRENT { 1300, 1300, 1250 } // Values in milliamps
|
||||
//#define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
|
||||
@@ -1548,6 +1551,7 @@
|
||||
//#define LCD_INFO_MENU
|
||||
#if ENABLED(LCD_INFO_MENU)
|
||||
//#define LCD_PRINTER_INFO_IS_BOOTSCREEN // Show bootscreen(s) instead of Printer Info pages
|
||||
//#define BUILD_INFO_MENU_ITEM // Add a menu item to display the build date and time
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -1615,6 +1619,10 @@
|
||||
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
|
||||
#define SOUND_ON_DEFAULT // Buzzer/speaker default enabled state
|
||||
|
||||
#if ENABLED(U8GLIB_SSD1309)
|
||||
//#define LCD_DOUBLE_BUFFER // Optimize display updates. Costs ~1K of SRAM.
|
||||
#endif
|
||||
|
||||
#if HAS_WIRED_LCD
|
||||
//#define DOUBLE_LCD_FRAMERATE // Not recommended for slow boards.
|
||||
#endif
|
||||
@@ -1866,7 +1874,7 @@
|
||||
*
|
||||
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
|
||||
* INT --> SD_DETECT_PIN [1]
|
||||
* SS --> SDSS
|
||||
* SS --> SD_SS_PIN
|
||||
*
|
||||
* [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
|
||||
*/
|
||||
@@ -1893,7 +1901,7 @@
|
||||
//#define USE_OTG_USB_HOST
|
||||
|
||||
#if DISABLED(USE_OTG_USB_HOST)
|
||||
#define USB_CS_PIN SDSS
|
||||
#define USB_CS_PIN SD_SS_PIN
|
||||
#define USB_INTR_PIN SD_DETECT_PIN
|
||||
#endif
|
||||
#endif
|
||||
@@ -2004,7 +2012,7 @@
|
||||
#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
|
||||
//#define DOGM_SPI_DELAY_US 5 // (µs) Delay after each SPI transfer
|
||||
|
||||
//#define LIGHTWEIGHT_UI
|
||||
#if ENABLED(LIGHTWEIGHT_UI)
|
||||
@@ -2034,17 +2042,17 @@
|
||||
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
|
||||
//#define STATUS_HEAT_POWER // Show heater output power as a vertical bar
|
||||
|
||||
// Frivolous Game Options
|
||||
//#define MARLIN_BRICKOUT
|
||||
//#define MARLIN_INVADERS
|
||||
//#define MARLIN_SNAKE
|
||||
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
|
||||
#define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens
|
||||
//#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay
|
||||
|
||||
// Frivolous Game Options
|
||||
//#define MARLIN_BRICKOUT
|
||||
//#define MARLIN_INVADERS
|
||||
//#define MARLIN_SNAKE
|
||||
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -2223,7 +2231,7 @@
|
||||
|
||||
// Developer menu (accessed by touching "About Printer" copyright text)
|
||||
//#define TOUCH_UI_DEVELOPER_MENU
|
||||
#endif
|
||||
#endif // TOUCH_UI_FTDI_EVE
|
||||
|
||||
//
|
||||
// Classic UI Options
|
||||
@@ -2257,7 +2265,7 @@
|
||||
// ADC Button Debounce
|
||||
//
|
||||
#if HAS_ADC_BUTTONS
|
||||
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // Increase if buttons bounce or repeat too fast
|
||||
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (count) Increase if buttons bounce or repeat too fast
|
||||
#endif
|
||||
|
||||
// @section safety
|
||||
@@ -2298,7 +2306,7 @@
|
||||
|
||||
//#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
|
||||
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
|
||||
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
|
||||
#define DOUBLECLICK_MAX_INTERVAL 1250 // (ms) Maximum interval between clicks.
|
||||
// Note: Extra time may be added to mitigate controller latency.
|
||||
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on double-click when printer is idle.
|
||||
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
||||
@@ -2630,19 +2638,23 @@
|
||||
#define MAX_CMD_SIZE 96
|
||||
#define BUFSIZE 4
|
||||
|
||||
// Transmission to Host Buffer Size
|
||||
// To save 386 bytes of flash (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
|
||||
// To buffer a simple "ok" you need 4 bytes.
|
||||
// For ADVANCED_OK (M105) you need 32 bytes.
|
||||
// For debug-echo: 128 bytes for the optimal speed.
|
||||
// Other output doesn't need to be that speedy.
|
||||
// :[0, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||
/**
|
||||
* Host Transmit Buffer Size
|
||||
* - Costs 386 bytes of flash and TX_BUFFER_SIZE+3 bytes of SRAM (if not 0).
|
||||
* - 4 bytes required to buffer a simple "ok".
|
||||
* - 32 bytes for ADVANCED_OK (M105).
|
||||
* - 128 bytes for the optimal speed of 'debug-echo:'
|
||||
* - Other output doesn't need to be that speedy.
|
||||
* :[0, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||
*/
|
||||
#define TX_BUFFER_SIZE 0
|
||||
|
||||
// Host Receive Buffer Size
|
||||
// Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough.
|
||||
// To use flow control, set this buffer size to at least 1024 bytes.
|
||||
// :[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
|
||||
/**
|
||||
* Host Receive Buffer Size
|
||||
* Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough.
|
||||
* To use flow control, set this buffer size to at least 1024 bytes.
|
||||
* :[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
|
||||
*/
|
||||
//#define RX_BUFFER_SIZE 1024
|
||||
|
||||
#if RX_BUFFER_SIZE >= 1024
|
||||
@@ -3909,7 +3921,7 @@
|
||||
/**
|
||||
* Extra options for the M114 "Current Position" report
|
||||
*/
|
||||
//#define M114_DETAIL // Use 'M114` for details to check planner calculations
|
||||
//#define M114_DETAIL // Use 'M114 D' for details to check planner calculations
|
||||
//#define M114_REALTIME // Real current position based on forward kinematics
|
||||
//#define M114_LEGACY // M114 used to synchronize on every call. Enable if needed.
|
||||
|
||||
@@ -3956,7 +3968,6 @@
|
||||
* Spend 28 bytes of SRAM to optimize the G-code parser
|
||||
*/
|
||||
#define FASTER_GCODE_PARSER
|
||||
|
||||
#if ENABLED(FASTER_GCODE_PARSER)
|
||||
//#define GCODE_QUOTED_STRINGS // Support for quoted string parameters
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
//#define STRING_DISTRIBUTION_DATE "2024-11-04"
|
||||
//#define STRING_DISTRIBUTION_DATE "2025-03-18"
|
||||
|
||||
/**
|
||||
* The protocol for communication to the host. Protocol indicates communication
|
||||
|
||||
+40
-43
@@ -62,6 +62,11 @@ motherboard = BOARD_RAMPS_14_EFB
|
||||
serial_port = 0
|
||||
baudrate = 250000
|
||||
|
||||
string_config_h_author = "(default from config.ini)"
|
||||
|
||||
capabilities_report = on
|
||||
extended_capabilities_report = on
|
||||
|
||||
use_watchdog = on
|
||||
thermal_protection_hotends = on
|
||||
thermal_protection_hysteresis = 4
|
||||
@@ -77,9 +82,7 @@ temp_sensor_0 = 1
|
||||
temp_hysteresis = 3
|
||||
heater_0_mintemp = 5
|
||||
heater_0_maxtemp = 275
|
||||
preheat_1_temp_hotend = 180
|
||||
|
||||
bang_max = 255
|
||||
pidtemp = on
|
||||
pid_k1 = 0.95
|
||||
pid_max = 255
|
||||
@@ -89,6 +92,14 @@ default_kp = 22.20
|
||||
default_ki = 1.08
|
||||
default_kd = 114.00
|
||||
|
||||
temp_sensor_bed = 1
|
||||
bed_mintemp = 5
|
||||
bed_maxtemp = 150
|
||||
|
||||
thermal_protection_bed = on
|
||||
thermal_protection_bed_hysteresis = 2
|
||||
thermal_protection_bed_period = 20
|
||||
|
||||
x_driver_type = A4988
|
||||
y_driver_type = A4988
|
||||
z_driver_type = A4988
|
||||
@@ -121,10 +132,10 @@ default_max_acceleration = { 3000, 3000, 100, 10000 }
|
||||
homing_feedrate_mm_m = { (50*60), (50*60), (4*60) }
|
||||
homing_bump_divisor = { 2, 2, 4 }
|
||||
|
||||
x_enable_on = 0
|
||||
y_enable_on = 0
|
||||
z_enable_on = 0
|
||||
e_enable_on = 0
|
||||
x_enable_on = LOW
|
||||
y_enable_on = LOW
|
||||
z_enable_on = LOW
|
||||
e_enable_on = LOW
|
||||
|
||||
invert_x_dir = false
|
||||
invert_y_dir = true
|
||||
@@ -136,11 +147,6 @@ step_state_x = HIGH
|
||||
step_state_y = HIGH
|
||||
step_state_z = HIGH
|
||||
|
||||
disable_x = off
|
||||
disable_y = off
|
||||
disable_z = off
|
||||
disable_e = off
|
||||
|
||||
proportional_font_ratio = 1.0
|
||||
default_nominal_filament_dia = 1.75
|
||||
|
||||
@@ -153,18 +159,13 @@ default_retract_acceleration = 3000
|
||||
default_minimumfeedrate = 0.0
|
||||
default_mintravelfeedrate = 0.0
|
||||
|
||||
minimum_planner_speed = 0.05
|
||||
min_steps_per_segment = 6
|
||||
default_minsegmenttime = 20000
|
||||
|
||||
[config:basic]
|
||||
bed_overshoot = 10
|
||||
busy_while_heating = on
|
||||
default_ejerk = 5.0
|
||||
default_keepalive_interval = 2
|
||||
default_leveling_fade_height = 0.0
|
||||
disable_other_extruders = on
|
||||
display_charset_hd44780 = JAPANESE
|
||||
eeprom_boot_silent = on
|
||||
eeprom_chitchat = on
|
||||
endstoppullups = on
|
||||
@@ -173,10 +174,8 @@ extrude_mintemp = 170
|
||||
host_keepalive_feature = on
|
||||
hotend_overshoot = 15
|
||||
jd_handle_small_segments = on
|
||||
lcd_info_screen_style = 0
|
||||
lcd_language = en
|
||||
max_bed_power = 255
|
||||
mesh_inset = 0
|
||||
|
||||
min_software_endstops = on
|
||||
max_software_endstops = on
|
||||
min_software_endstop_x = on
|
||||
@@ -185,50 +184,48 @@ min_software_endstop_z = on
|
||||
max_software_endstop_x = on
|
||||
max_software_endstop_y = on
|
||||
max_software_endstop_z = on
|
||||
preheat_1_fan_speed = 0
|
||||
|
||||
preheat_1_label = "PLA"
|
||||
preheat_1_temp_hotend = 180
|
||||
preheat_1_temp_bed = 70
|
||||
preheat_1_fan_speed = 0
|
||||
|
||||
preheat_2_label = "ABS"
|
||||
preheat_2_temp_hotend = 240
|
||||
preheat_2_temp_bed = 110
|
||||
preheat_2_fan_speed = 0
|
||||
|
||||
prevent_cold_extrusion = on
|
||||
prevent_lengthy_extrude = on
|
||||
printjob_timer_autostart = on
|
||||
probing_margin = 10
|
||||
show_bootscreen = on
|
||||
soft_pwm_scale = 0
|
||||
string_config_h_author = "(none, default config)"
|
||||
|
||||
temp_bed_hysteresis = 3
|
||||
temp_bed_residency_time = 10
|
||||
temp_bed_window = 1
|
||||
temp_residency_time = 10
|
||||
temp_window = 1
|
||||
validate_homing_endstops = on
|
||||
xy_probe_feedrate = (133*60)
|
||||
z_clearance_between_probes = 5
|
||||
z_clearance_deploy_probe = 10
|
||||
z_clearance_multi_probe = 5
|
||||
|
||||
editable_steps_per_unit = on
|
||||
|
||||
[config:advanced]
|
||||
arc_support = on
|
||||
auto_report_temperatures = on
|
||||
|
||||
autotemp = on
|
||||
autotemp_min = 210
|
||||
autotemp_max = 250
|
||||
autotemp_factor = 0.1f
|
||||
autotemp_oldweight = 0.98
|
||||
bed_check_interval = 5000
|
||||
|
||||
default_stepper_timeout_sec = 120
|
||||
default_volumetric_extruder_limit = 0.00
|
||||
disable_idle_x = on
|
||||
disable_idle_y = on
|
||||
disable_idle_z = on
|
||||
disable_idle_e = on
|
||||
e0_auto_fan_pin = -1
|
||||
encoder_100x_steps_per_sec = 80
|
||||
encoder_10x_steps_per_sec = 30
|
||||
encoder_rate_multiplier = on
|
||||
extended_capabilities_report = on
|
||||
extruder_auto_fan_speed = 255
|
||||
extruder_auto_fan_temperature = 50
|
||||
fanmux0_pin = -1
|
||||
fanmux1_pin = -1
|
||||
fanmux2_pin = -1
|
||||
faster_gcode_parser = on
|
||||
debug_flags_gcode = on
|
||||
homing_bump_mm = { 5, 5, 2 }
|
||||
max_arc_segment_mm = 1.0
|
||||
min_arc_segment_mm = 0.1
|
||||
@@ -237,11 +234,11 @@ n_arc_correction = 25
|
||||
serial_overrun_protection = on
|
||||
slowdown = on
|
||||
slowdown_divisor = 2
|
||||
temp_sensor_bed = 0
|
||||
thermal_protection_bed_hysteresis = 2
|
||||
thermocouple_max_errors = 15
|
||||
tx_buffer_size = 0
|
||||
|
||||
bed_check_interval = 5000
|
||||
watch_bed_temp_increase = 2
|
||||
watch_bed_temp_period = 60
|
||||
|
||||
watch_temp_increase = 2
|
||||
watch_temp_period = 20
|
||||
watch_temp_period = 40
|
||||
|
||||
@@ -23,43 +23,41 @@
|
||||
|
||||
/**
|
||||
* Define SPI Pins: SCK, MISO, MOSI, SS
|
||||
* Platform pins have parentheses, e.g., "(53)", so we cannot use them.
|
||||
*/
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
|
||||
#define AVR_SCK_PIN 13
|
||||
#define AVR_MISO_PIN 12
|
||||
#define AVR_MOSI_PIN 11
|
||||
#define AVR_SS_PIN 10
|
||||
#define _PIN_SPI_SCK 13
|
||||
#define _PIN_SPI_MISO 12
|
||||
#define _PIN_SPI_MOSI 11
|
||||
#define _PIN_SPI_SS 10
|
||||
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
|
||||
#define AVR_SCK_PIN 7
|
||||
#define AVR_MISO_PIN 6
|
||||
#define AVR_MOSI_PIN 5
|
||||
#define AVR_SS_PIN 4
|
||||
#define _PIN_SPI_SCK 7
|
||||
#define _PIN_SPI_MISO 6
|
||||
#define _PIN_SPI_MOSI 5
|
||||
#define _PIN_SPI_SS 4
|
||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
#define AVR_SCK_PIN 52
|
||||
#define AVR_MISO_PIN 50
|
||||
#define AVR_MOSI_PIN 51
|
||||
#define AVR_SS_PIN 53
|
||||
#define _PIN_SPI_SCK 52
|
||||
#define _PIN_SPI_MISO 50
|
||||
#define _PIN_SPI_MOSI 51
|
||||
#define _PIN_SPI_SS 53
|
||||
#elif defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
|
||||
#define AVR_SCK_PIN 21
|
||||
#define AVR_MISO_PIN 23
|
||||
#define AVR_MOSI_PIN 22
|
||||
#define AVR_SS_PIN 20
|
||||
#define _PIN_SPI_SCK 21
|
||||
#define _PIN_SPI_MISO 23
|
||||
#define _PIN_SPI_MOSI 22
|
||||
#define _PIN_SPI_SS 20
|
||||
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||
#define AVR_SCK_PIN 10
|
||||
#define AVR_MISO_PIN 12
|
||||
#define AVR_MOSI_PIN 11
|
||||
#define AVR_SS_PIN 16
|
||||
#define _PIN_SPI_SCK 10
|
||||
#define _PIN_SPI_MISO 12
|
||||
#define _PIN_SPI_MOSI 11
|
||||
#define _PIN_SPI_SS 16
|
||||
#endif
|
||||
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN AVR_SCK_PIN
|
||||
#define SD_SCK_PIN _PIN_SPI_SCK
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN AVR_MISO_PIN
|
||||
#define SD_MISO_PIN _PIN_SPI_MISO
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN AVR_MOSI_PIN
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN AVR_SS_PIN
|
||||
#define SD_MOSI_PIN _PIN_SPI_MOSI
|
||||
#endif
|
||||
|
||||
@@ -48,7 +48,7 @@ uint16_t MarlinHAL::adc_result;
|
||||
|
||||
void MarlinHAL::init() {
|
||||
#if HAS_MEDIA
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#endif
|
||||
usb_task_init(); // Initialize the USB stack
|
||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||
|
||||
@@ -35,67 +35,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
extern DefaultSerial2 MSerial1;
|
||||
extern DefaultSerial3 MSerial2;
|
||||
extern DefaultSerial4 MSerial3;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL1 customizedSerial1
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL2 customizedSerial2
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL3 customizedSerial3
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 3)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if WITHIN(MMU_SERIAL_PORT, 0, 3)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be from 0 to 3."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3."
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
|
||||
#include "MarlinSerial.h"
|
||||
#include "MarlinSerialUSB.h"
|
||||
|
||||
@@ -600,9 +600,8 @@
|
||||
OUT_WRITE(SPI_EEPROM1_CS_PIN, HIGH);
|
||||
OUT_WRITE(SPI_EEPROM2_CS_PIN, HIGH);
|
||||
OUT_WRITE(SPI_FLASH_CS_PIN, HIGH);
|
||||
WRITE(SD_SS_PIN, HIGH);
|
||||
|
||||
OUT_WRITE(SDSS, LOW);
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
WRITE(SD_SS_PIN, LOW);
|
||||
|
||||
PIO_Configure(
|
||||
g_APinDescription[SPI_PIN].pPort,
|
||||
@@ -767,7 +766,7 @@
|
||||
|
||||
// Disable PIO on A26 and A27
|
||||
REG_PIOA_PDR = 0x0C000000;
|
||||
OUT_WRITE(SDSS, HIGH);
|
||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
||||
|
||||
// Reset SPI0 (from sam lib)
|
||||
SPI0->SPI_CR = SPI_CR_SPIDIS;
|
||||
|
||||
@@ -33,6 +33,21 @@
|
||||
#include "../../core/types.h"
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
extern DefaultSerial2 MSerial1;
|
||||
extern DefaultSerial3 MSerial2;
|
||||
extern DefaultSerial4 MSerial3;
|
||||
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#define EP_SERIAL_PORT(N) customizedSerial##N
|
||||
#define USB_SERIAL_PORT(N) customizedSerial##N
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
// Define constants and variables for buffering incoming serial data. We're
|
||||
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||
// location to which to write the next incoming character and rx_buffer_tail
|
||||
|
||||
@@ -291,7 +291,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
|
||||
uint32_t *p1 = (uint32_t*)addrflash;
|
||||
uint32_t *p2 = (uint32_t*)data;
|
||||
int count = 0;
|
||||
for (i =0; i<PageSize >> 2; i++) {
|
||||
for (i = 0; i < PageSize >> 2; i++) {
|
||||
if (p1[i] != p2[i]) {
|
||||
uint32_t delta = p1[i] ^ p2[i];
|
||||
while (delta) {
|
||||
|
||||
@@ -26,39 +26,36 @@
|
||||
*
|
||||
* Available chip select pins for HW SPI are 4 10 52 77 87
|
||||
*/
|
||||
#if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87
|
||||
#if SDSS == 4
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#elif SDSS == 10
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#elif SDSS == 52
|
||||
#define SPI_PIN 86
|
||||
#define SPI_CHAN 2
|
||||
#elif SDSS == 77
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#else
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#endif
|
||||
#define SD_SCK_PIN 76
|
||||
#define SD_MISO_PIN 74
|
||||
#define SD_MOSI_PIN 75
|
||||
#else
|
||||
// defaults
|
||||
#define SOFTWARE_SPI
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN 52
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN 50
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 51
|
||||
#endif
|
||||
#if SD_SS_PIN == 4 || SD_SS_PIN == 10 || SD_SS_PIN == 52 || SD_SS_PIN == 77 || SD_SS_PIN == 87
|
||||
#define SD_SCK_PIN 76
|
||||
#define SD_MISO_PIN 74
|
||||
#define SD_MOSI_PIN 75
|
||||
#endif
|
||||
|
||||
/* A.28, A.29, B.21, C.26, C.29 */
|
||||
#define SD_SS_PIN SDSS
|
||||
#if SD_SS_PIN == 4
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#elif SD_SS_PIN == 10
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#elif SD_SS_PIN == 52
|
||||
#define SPI_PIN 86
|
||||
#define SPI_CHAN 2
|
||||
#elif SD_SS_PIN == 77
|
||||
#define SPI_PIN 77
|
||||
#define SPI_CHAN 0
|
||||
#elif SD_SS_PIN == 87
|
||||
#define SPI_PIN 87
|
||||
#define SPI_CHAN 1
|
||||
#else
|
||||
#define SOFTWARE_SPI
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN 52
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN 50
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 51
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,16 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define SD_SS_PIN SDSS
|
||||
#define SD_SCK_PIN 18
|
||||
#define SD_MISO_PIN 19
|
||||
#define SD_MOSI_PIN 23
|
||||
#define PIN_SPI_SCK 18
|
||||
#define PIN_SPI_MISO 19
|
||||
#define PIN_SPI_MOSI 23
|
||||
|
||||
#ifndef SD_SCK_PIN
|
||||
#define SD_SCK_PIN PIN_SPI_SCK
|
||||
#endif
|
||||
#ifndef SD_MISO_PIN
|
||||
#define SD_MISO_PIN PIN_SPI_MISO
|
||||
#endif
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN PIN_SPI_MOSI
|
||||
#endif
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../core/serial.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
|
||||
#include "../../core/serial.h"
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
@@ -30,69 +30,18 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "../../core/macros.h"
|
||||
#include "../shared/Marduino.h"
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
|
||||
#include "fastio.h"
|
||||
#include "timers.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
#define NUM_UARTS 4
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#error "USB Serial is not supported on HC32F460"
|
||||
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#define MYSERIAL1 MSERIAL(1) // Dummy port
|
||||
static_assert(false, "SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ".")
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#error "USB Serial is not supported on HC32F460"
|
||||
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#define MYSERIAL2 MSERIAL(1) // Dummy port
|
||||
static_assert(false, "SERIAL_PORT_2 must be from 1 to " STRINGIFY(NUM_UARTS) ".")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#error "USB Serial is not supported on HC32F460"
|
||||
#elif WITHIN(SERIAL_PORT_3, 1, NUM_UARTS)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#define MYSERIAL3 MSERIAL(1) // Dummy port
|
||||
static_assert(false, "SERIAL_PORT_3 must be from 1 to " STRINGIFY(NUM_UARTS) ".")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#error "USB Serial is not supported on HC32F460"
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#define LCD_SERIAL MSERIAL(1) // Dummy port
|
||||
static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ".")
|
||||
#endif
|
||||
|
||||
#if HAS_DGUS_LCD
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
//
|
||||
// Emergency Parser
|
||||
|
||||
@@ -24,6 +24,14 @@
|
||||
#include "../../core/serial_hook.h"
|
||||
#include <drivers/usart/Usart.h>
|
||||
|
||||
#define SERIAL_INDEX_MIN 1
|
||||
#define SERIAL_INDEX_MAX 4
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
// Optionally set uart IRQ priority to reduce overflow errors
|
||||
//#define UART_RX_IRQ_PRIO 1
|
||||
//#define UART_TX_IRQ_PRIO 1
|
||||
|
||||
@@ -11,7 +11,7 @@ The HC32F460 HAL is designed to be generic enough for any HC32F460-based board.
|
||||
- Examine the board's main processor. (Refer the naming key in `hc32.ini`.)
|
||||
- Extend the `HC32F460C_common` base env for 256K, or `HC32F460E_common` for 512K.
|
||||
3. Determine your board's application start address (see [below](#finding-the-application-start-address))
|
||||
4. Set `board_build.ld_args.flash_start` to the app start address once you've found it. If your board doesn't use a bootloader, you may be able to use the "ICSP" header or DFU. This document will be updated once we have more information about flashing without a bootloader.
|
||||
4. Set `board_upload.offset_address` to the app start address once you've found it. If your board doesn't use a bootloader, you may be able to use the "ICSP" header or DFU. This document will be updated once we have more information about flashing without a bootloader.
|
||||
|
||||
### Finding the application start address
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define _HC32_APP_CONFIG_H_
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "sysclock.h"
|
||||
|
||||
//
|
||||
// dev mode
|
||||
@@ -64,12 +65,8 @@
|
||||
// redirect printf to host serial
|
||||
#define REDIRECT_PRINTF_TO_SERIAL 1
|
||||
|
||||
// F_CPU must be known at compile time, but on HC32F460 it's not.
|
||||
// Thus we assume HCLK to be 200MHz, as that's what is configured in
|
||||
// 'core_hook_sysclock_init' in 'sysclock.cpp'.
|
||||
// If you face issues with this assumption, please double-check with the values
|
||||
// printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
|
||||
// see also: HAL_TIMER_RATE in timers.h
|
||||
#define F_CPU 200000000 // 200MHz HCLK
|
||||
// F_CPU is F_HCLK, as that's the main CPU core's clock.
|
||||
// see 'sysclock.h' for more information.
|
||||
#define F_CPU F_HCLK
|
||||
|
||||
#endif // _HC32_APP_CONFIG_H_
|
||||
|
||||
Binary file not shown.
@@ -94,7 +94,7 @@
|
||||
#error "SERIAL_DMA requires USART_RX_DMA_SUPPORT to be enabled in the arduino core."
|
||||
#endif
|
||||
|
||||
// Before arduino core version 1.2.0, USART_RX_DMA_SUPPORT did not implement
|
||||
// Before arduino core version 1.2.0, USART_RX_DMA_SUPPORT did not implement
|
||||
// core_hook_usart_rx_irq, which is required for the emergency parser.
|
||||
// With 1.2.0, this was fixed (see https://github.com/shadow578/framework-arduino-hc32f46x/pull/25).
|
||||
#if ENABLED(EMERGENCY_PARSER) && ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 2, 0)
|
||||
|
||||
@@ -26,64 +26,144 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_HC32
|
||||
|
||||
// Get BOARD_XTAL_FREQUENCY from configuration / pins
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "sysclock.h"
|
||||
|
||||
#include <core_hooks.h>
|
||||
#include <drivers/sysclock/sysclock_util.h>
|
||||
|
||||
/***
|
||||
* @brief Automatically calculate M, N, P values for the MPLL to reach a target frequency.
|
||||
* @param input_frequency The input frequency.
|
||||
* @param target_frequency The target frequency.
|
||||
* @return The MPLL configuration structure. Q and R are not set.
|
||||
*
|
||||
* @note
|
||||
* Simplified MPLL block diagram, with intermediary clocks (1) = VCO_in, (2) = VCO_out:
|
||||
*
|
||||
* INPUT -> [/ M] -(1)-> [* N] -(2)-|-> [/ P] -> MPLL-P
|
||||
*/
|
||||
constexpr stc_clk_mpll_cfg_t get_mpll_config(double input_frequency, double target_frequency) {
|
||||
// PLL input clock divider: M in [1, 24]
|
||||
for (uint32_t M = 1; M <= 24; M++) {
|
||||
double f_vco_in = input_frequency / M;
|
||||
|
||||
// 1 <= VCO_in <= 25 MHz
|
||||
if (f_vco_in < 1e6 || f_vco_in > 25e6) continue;
|
||||
|
||||
// VCO multiplier: N in [20, 480]
|
||||
for (uint32_t N = 20; N <= 480; N++) {
|
||||
double f_vco_out = f_vco_in * N;
|
||||
|
||||
// 240 <= VCO_out <= 480 MHz
|
||||
if (f_vco_out < 240e6 || f_vco_out > 480e6) continue;
|
||||
|
||||
// Output "P" divider: P in [2, 16]
|
||||
for (uint32_t P = 2; P <= 16; P++) {
|
||||
double f_calculated_out = f_vco_out / P;
|
||||
if (f_calculated_out == target_frequency) {
|
||||
// Found a match, return it
|
||||
return {
|
||||
.PllpDiv = P,
|
||||
.PllqDiv = P, // Don't care for Q and R
|
||||
.PllrDiv = P, // "
|
||||
.plln = N,
|
||||
.pllmDiv = M
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If no valid M, N, P found, return invalid config
|
||||
return { 0, 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the division factor required to get the target frequency from the input frequency.
|
||||
* @tparam input_freq The input frequency.
|
||||
* @tparam target_freq The target frequency.
|
||||
* @return The division factor.
|
||||
*/
|
||||
template <uint32_t input_freq, uint32_t target_freq>
|
||||
constexpr en_clk_sysclk_div_factor_t get_division_factor() {
|
||||
// Calculate the divider to get the target frequency
|
||||
constexpr float fdivider = static_cast<float>(input_freq) / static_cast<float>(target_freq);
|
||||
constexpr int divider = static_cast<int>(fdivider);
|
||||
|
||||
// divider must be an integer
|
||||
static_assert(fdivider == divider, "Target frequency not achievable, divider must be an integer");
|
||||
|
||||
// divider must be between 1 and 64 (enum range), and must be a power of 2
|
||||
static_assert(divider >= 1 && divider <= 64, "Invalid divider, out of range");
|
||||
static_assert((divider & (divider - 1)) == 0, "Invalid divider, not a power of 2");
|
||||
|
||||
// return the divider
|
||||
switch (divider) {
|
||||
case 1: return ClkSysclkDiv1;
|
||||
case 2: return ClkSysclkDiv2;
|
||||
case 4: return ClkSysclkDiv4;
|
||||
case 8: return ClkSysclkDiv8;
|
||||
case 16: return ClkSysclkDiv16;
|
||||
case 32: return ClkSysclkDiv32;
|
||||
case 64: return ClkSysclkDiv64;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Validate the runtime clocks match the expected values.
|
||||
*/
|
||||
void validate_system_clocks() {
|
||||
#define CLOCK_ASSERT(expected, actual) \
|
||||
if (expected != actual) { \
|
||||
SERIAL_ECHOPGM( \
|
||||
"Clock Mismatch for " #expected ": " \
|
||||
"expected ", expected, \
|
||||
", got ", actual \
|
||||
); \
|
||||
CORE_ASSERT_FAIL("Clock Mismatch: " #expected); \
|
||||
}
|
||||
|
||||
update_system_clock_frequencies();
|
||||
|
||||
CLOCK_ASSERT(F_SYSTEM_CLOCK, SYSTEM_CLOCK_FREQUENCIES.system);
|
||||
CLOCK_ASSERT(F_HCLK, SYSTEM_CLOCK_FREQUENCIES.hclk);
|
||||
CLOCK_ASSERT(F_EXCLK, SYSTEM_CLOCK_FREQUENCIES.exclk);
|
||||
CLOCK_ASSERT(F_PCLK0, SYSTEM_CLOCK_FREQUENCIES.pclk0);
|
||||
CLOCK_ASSERT(F_PCLK1, SYSTEM_CLOCK_FREQUENCIES.pclk1);
|
||||
CLOCK_ASSERT(F_PCLK2, SYSTEM_CLOCK_FREQUENCIES.pclk2);
|
||||
CLOCK_ASSERT(F_PCLK3, SYSTEM_CLOCK_FREQUENCIES.pclk3);
|
||||
CLOCK_ASSERT(F_PCLK4, SYSTEM_CLOCK_FREQUENCIES.pclk4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure HC32 system clocks.
|
||||
*
|
||||
* This function is called by the Arduino core early in the startup process, before setup() is called.
|
||||
* It is used to configure the system clocks to the desired state.
|
||||
*
|
||||
* See https://github.com/MarlinFirmware/Marlin/pull/27099 for more information.
|
||||
*/
|
||||
void core_hook_sysclock_init() {
|
||||
// Set wait cycles, as we are about to switch to 200 MHz HCLK
|
||||
sysclock_configure_flash_wait_cycles();
|
||||
sysclock_configure_sram_wait_cycles();
|
||||
|
||||
// Configure MPLLp to 200 MHz output, with different settings depending on XTAL availability
|
||||
#if BOARD_XTAL_FREQUENCY == 8000000 // 8 MHz XTAL
|
||||
// - M = 1 => 8 MHz / 1 = 8 MHz
|
||||
// - N = 50 => 8 MHz * 50 = 400 MHz
|
||||
// - P = 2 => 400 MHz / 2 = 200 MHz (sysclk)
|
||||
// - Q,R = 4 => 400 MHz / 4 = 100 MHz (dont care)
|
||||
stc_clk_mpll_cfg_t pllConf = {
|
||||
.PllpDiv = 2u, // P
|
||||
.PllqDiv = 4u, // Q
|
||||
.PllrDiv = 4u, // R
|
||||
.plln = 50u, // N
|
||||
.pllmDiv = 1u, // M
|
||||
};
|
||||
sysclock_configure_xtal();
|
||||
sysclock_configure_mpll(ClkPllSrcXTAL, &pllConf);
|
||||
// Select MPLL input frequency based on clock availability
|
||||
#if BOARD_XTAL_FREQUENCY == 8000000 || BOARD_XTAL_FREQUENCY == 16000000 // 8 MHz or 16 MHz XTAL
|
||||
constexpr uint32_t mpll_input_clock = BOARD_XTAL_FREQUENCY;
|
||||
|
||||
#elif BOARD_XTAL_FREQUENCY == 16000000 // 16 MHz XTAL
|
||||
// - M = 1 => 16 MHz / 1 = 16 MHz
|
||||
// - N = 50 => 16 MHz * 25 = 400 MHz
|
||||
// - P = 2 => 400 MHz / 2 = 200 MHz (sysclk)
|
||||
// - Q,R = 4 => 400 MHz / 4 = 100 MHz (dont care)
|
||||
stc_clk_mpll_cfg_t pllConf = {
|
||||
.PllpDiv = 2u, // P
|
||||
.PllqDiv = 4u, // Q
|
||||
.PllrDiv = 4u, // R
|
||||
.plln = 50u, // N
|
||||
.pllmDiv = 1u, // M
|
||||
};
|
||||
sysclock_configure_xtal();
|
||||
sysclock_configure_mpll(ClkPllSrcXTAL, &pllConf);
|
||||
|
||||
#warning "HC32F460 with 16 MHz XTAL has not been tested."
|
||||
#if BOARD_XTAL_FREQUENCY == 16000000
|
||||
#warning "HC32F460 with 16 MHz XTAL has not been tested."
|
||||
#endif
|
||||
|
||||
#else // HRC (16 MHz)
|
||||
// - M = 1 => 16 MHz / 1 = 16 MHz
|
||||
// - N = 25 => 16 MHz * 25 = 400 MHz
|
||||
// - P = 2 => 400 MHz / 2 = 200 MHz (sysclk)
|
||||
// - Q,R = 4 => 400 MHz / 4 = 100 MHz (dont care)
|
||||
stc_clk_mpll_cfg_t pllConf = {
|
||||
.PllpDiv = 2u, // P
|
||||
.PllqDiv = 4u, // Q
|
||||
.PllrDiv = 4u, // R
|
||||
.plln = 25u, // N
|
||||
.pllmDiv = 1u, // M
|
||||
};
|
||||
|
||||
constexpr uint32_t mpll_input_clock = 16000000;
|
||||
|
||||
sysclock_configure_hrc();
|
||||
sysclock_configure_mpll(ClkPllSrcHRC, &pllConf);
|
||||
|
||||
// HRC could have been configured by ICG to 20 MHz
|
||||
// TODO: handle gracefully if HRC is not 16 MHz
|
||||
@@ -91,29 +171,56 @@ void core_hook_sysclock_init() {
|
||||
panic("HRC is not 16 MHz");
|
||||
}
|
||||
|
||||
#ifdef BOARD_XTAL_FREQUENCY
|
||||
#if defined(BOARD_XTAL_FREQUENCY)
|
||||
#warning "No valid XTAL frequency defined, falling back to HRC."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// sysclk is now configured according to F_CPU (i.e., 200MHz PLL output)
|
||||
const uint32_t sysclock = F_CPU;
|
||||
// Automagically calculate MPLL configuration
|
||||
constexpr stc_clk_mpll_cfg_t pllConf = get_mpll_config(mpll_input_clock, F_SYSTEM_CLOCK);
|
||||
static_assert(pllConf.pllmDiv != 0 && pllConf.plln != 0 && pllConf.PllpDiv != 0, "MPLL auto-configuration failed");
|
||||
sysclock_configure_mpll(ClkPllSrcXTAL, &pllConf);
|
||||
|
||||
// Setup clock divisors for sysclk = 200 MHz
|
||||
// Note: PCLK1 is used for step+temp timers, and need to be kept at 50 MHz (until there is a better solution)
|
||||
// Setup clock divisors
|
||||
constexpr stc_clk_sysclk_cfg_t sysClkConf = {
|
||||
.enHclkDiv = ClkSysclkDiv1, // HCLK = 200 MHz (CPU)
|
||||
.enExclkDiv = ClkSysclkDiv2, // EXCLK = 100 MHz (SDIO)
|
||||
.enPclk0Div = ClkSysclkDiv2, // PCLK0 = 100 MHz (Timer6 (not used))
|
||||
.enPclk1Div = ClkSysclkDiv4, // PCLK1 = 50 MHz (USART, SPI, I2S, Timer0 (step+temp), TimerA (Servo))
|
||||
.enPclk2Div = ClkSysclkDiv8, // PCLK2 = 25 MHz (ADC)
|
||||
.enPclk3Div = ClkSysclkDiv8, // PCLK3 = 25 MHz (I2C, WDT)
|
||||
.enPclk4Div = ClkSysclkDiv2, // PCLK4 = 100 MHz (ADC ctl)
|
||||
.enHclkDiv = get_division_factor<F_SYSTEM_CLOCK, F_HCLK>(),
|
||||
.enExclkDiv = get_division_factor<F_SYSTEM_CLOCK, F_EXCLK>(),
|
||||
.enPclk0Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK0>(),
|
||||
.enPclk1Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK1>(),
|
||||
.enPclk2Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK2>(),
|
||||
.enPclk3Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK3>(),
|
||||
.enPclk4Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK4>(),
|
||||
};
|
||||
sysclock_set_clock_dividers(&sysClkConf);
|
||||
|
||||
// Set power mode, before switch
|
||||
power_mode_update_pre(F_SYSTEM_CLOCK);
|
||||
|
||||
// Switch to MPLL-P as system clock source
|
||||
CLK_SetSysClkSource(CLKSysSrcMPLL);
|
||||
|
||||
// Set power mode, after switch
|
||||
power_mode_update_post(F_SYSTEM_CLOCK);
|
||||
|
||||
// Verify clocks match expected values (at runtime)
|
||||
#if ENABLED(MARLIN_DEV_MODE) || ENABLED(ALWAYS_VALIDATE_CLOCKS)
|
||||
validate_system_clocks();
|
||||
#endif
|
||||
|
||||
// Verify clock configuration (at compile time)
|
||||
#if ARDUINO_CORE_VERSION_INT >= GET_VERSION_INT(1, 2, 0)
|
||||
assert_mpll_config_valid<
|
||||
mpll_input_clock,
|
||||
pllConf.pllmDiv,
|
||||
pllConf.plln,
|
||||
pllConf.PllpDiv,
|
||||
pllConf.PllqDiv,
|
||||
pllConf.PllrDiv
|
||||
>();
|
||||
|
||||
assert_system_clocks_valid<
|
||||
sysclock,
|
||||
F_SYSTEM_CLOCK,
|
||||
sysClkConf.enHclkDiv,
|
||||
sysClkConf.enPclk0Div,
|
||||
sysClkConf.enPclk1Div,
|
||||
@@ -122,18 +229,14 @@ void core_hook_sysclock_init() {
|
||||
sysClkConf.enPclk4Div,
|
||||
sysClkConf.enExclkDiv
|
||||
>();
|
||||
|
||||
static_assert(get_mpll_output_clock(
|
||||
mpll_input_clock,
|
||||
pllConf.pllmDiv,
|
||||
pllConf.plln,
|
||||
pllConf.PllpDiv
|
||||
) == F_SYSTEM_CLOCK, "actual MPLL output clock does not match F_SYSTEM_CLOCK");
|
||||
#endif
|
||||
|
||||
sysclock_set_clock_dividers(&sysClkConf);
|
||||
|
||||
// Set power mode
|
||||
power_mode_update_pre(sysclock);
|
||||
|
||||
// Switch to MPLL as sysclk source
|
||||
CLK_SetSysClkSource(CLKSysSrcMPLL);
|
||||
|
||||
// Set power mode
|
||||
power_mode_update_post(sysclock);
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ARCH_HC32
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* HC32F460 system clock configuration.
|
||||
*
|
||||
* With the HC32 HAL, the various peripheral clocks (including the CPU clock) are derived
|
||||
* from the main PLL (MPLL-P) output (referred to at F_SYSTEM_CLOCK).
|
||||
*
|
||||
* F_SYSTEM_CLOCK is the target frequency of the main PLL, and the PLL is automatically configured
|
||||
* to achieve this frequency.
|
||||
*
|
||||
* The peripheral clocks are the result of integer division of F_SYSTEM_CLOCK.
|
||||
* Their target frequencies are defined here, and the required division factors are calculated automatically.
|
||||
* Note that the division factor must be a power of 2 between 1 and 64.
|
||||
* If the target frequency is not achievable, a compile-time error will be generated.
|
||||
*
|
||||
* Additionally, there are interdependencies between the peripheral clocks, which are described in
|
||||
* Section 4.4 "Working Clock Specifications" of the HC32F460 Reference Manual.
|
||||
* With Arduino core >= 1.2.0, these interdependencies are checked at compile time.
|
||||
* On earlier versions, you are on your own.
|
||||
*
|
||||
* For all clock frequencies, they can be checked at runtime by enabling the 'ALWAYS_VALIDATE_CLOCKS' define.
|
||||
* In MARLIN_DEV_MODE, they will also be printed to the serial console by 'MarlinHAL::HAL_clock_frequencies_dump'.
|
||||
*
|
||||
* See https://github.com/MarlinFirmware/Marlin/pull/27099 for more information.
|
||||
*/
|
||||
|
||||
// Target peripheral clock frequencies, must be integer divisors of F_SYSTEM_CLOCK.
|
||||
// Changing the frequency here will automagically update everything else.
|
||||
#define F_HCLK 200000000UL // 200 MHz; CPU
|
||||
#define F_EXCLK (F_HCLK / 2) // 100 MHz; SDIO
|
||||
#define F_PCLK0 (F_HCLK / 2) // 100 MHz; Timer6 (unused)
|
||||
#define F_PCLK1 (F_HCLK / 4) // 50 MHz; USART, SPI, Timer0 (step + temp), TimerA (Servo)
|
||||
#define F_PCLK2 (F_HCLK / 8) // 25 MHz; ADC Sampling
|
||||
#define F_PCLK3 (F_HCLK / 8) // 25 MHz; I2C, WDT
|
||||
#define F_PCLK4 (F_HCLK / 2) // 100 MHz; ADC Control
|
||||
|
||||
// MPLL-P clock target frequency. This must be >= the highest peripheral clock frequency.
|
||||
// PLL config is automatically calculated based on this value.
|
||||
#define F_SYSTEM_CLOCK F_HCLK
|
||||
|
||||
// The Peripheral clocks are only checked at runtime if this is enabled OR MARLIN_DEV_MODE is enabled.
|
||||
// Compile time checks are always performed with Arduino core version >= 1.2.0.
|
||||
#define ALWAYS_VALIDATE_CLOCKS 1
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <Timer0.h>
|
||||
#include "sysclock.h"
|
||||
|
||||
//
|
||||
// Timer Types
|
||||
@@ -42,17 +43,15 @@ extern Timer0 step_timer;
|
||||
* HAL_TIMER_RATE must be known at compile time since it's used to calculate
|
||||
* STEPPER_TIMER_RATE, which is used in 'constexpr' calculations.
|
||||
* On the HC32F460 the timer rate depends on PCLK1, which is derived from the
|
||||
* system clock configured at runtime. As a workaround, we use the existing
|
||||
* assumption of a 200MHz clock, defining F_CPU as 200000000, then configure PCLK1
|
||||
* as F_CPU with a divider of 4 in 'sysclock.cpp::core_hook_sysclock_init'.
|
||||
* system clock configured at runtime.
|
||||
* Thus we use the 'F_PCLK1' constant defined in 'sysclock.h'.
|
||||
*
|
||||
* If you face issues with this assumption, please double-check with the values
|
||||
* printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
|
||||
* See https://github.com/MarlinFirmware/Marlin/pull/27099 for more information.
|
||||
*
|
||||
* TODO: If the 'constexpr' requirement is ever lifted, use TIMER0_BASE_FREQUENCY instead
|
||||
* NOTE: If the 'constexpr' requirement is ever lifted, TIMER0_BASE_FREQUENCY could
|
||||
* be used instead. Tho this would probably not make any noticable difference.
|
||||
*/
|
||||
#define HAL_TIMER_RATE (F_CPU / 4) // i.e., 50MHz
|
||||
//#define HAL_TIMER_RATE TIMER0_BASE_FREQUENCY
|
||||
#define HAL_TIMER_RATE F_PCLK1
|
||||
|
||||
// Temperature timer
|
||||
#define TEMP_TIMER_NUM (&temp_timer)
|
||||
|
||||
@@ -38,9 +38,3 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 52
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN 53
|
||||
#endif
|
||||
#ifndef SDSS
|
||||
#define SDSS SD_SS_PIN
|
||||
#endif
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#include <CDCSerial.h>
|
||||
#include <usb/mscuser.h>
|
||||
|
||||
DefaultSerial1 USBSerial(false, UsbSerial);
|
||||
|
||||
uint32_t MarlinHAL::adc_result = 0;
|
||||
pin_t MarlinHAL::adc_pin = 0;
|
||||
|
||||
|
||||
@@ -38,72 +38,15 @@ extern "C" volatile uint32_t _millis;
|
||||
#include "../shared/math_32bit.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include "fastio.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#include <adc.h>
|
||||
#include <pinmapping.h>
|
||||
#include <CDCSerial.h>
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
|
||||
typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1;
|
||||
extern DefaultSerial1 USBSerial;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 3)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if MMU_SERIAL_PORT == -1
|
||||
#define MMU_SERIAL USBSerial
|
||||
#elif WITHIN(MMU_SERIAL_PORT, 0, 3)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL USBSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
|
||||
#endif
|
||||
#endif
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
//
|
||||
// Interrupts
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
DefaultSerial1 USBSerial(false, UsbSerial);
|
||||
|
||||
#if USING_HW_SERIAL0
|
||||
MarlinSerial _MSerial0(LPC_UART0);
|
||||
MSerialT MSerial0(true, _MSerial0);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <CDCSerial.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <WString.h>
|
||||
|
||||
@@ -30,6 +31,18 @@
|
||||
#endif
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1;
|
||||
extern DefaultSerial1 USBSerial;
|
||||
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#define USB_SERIAL_PORT(...) USBSerial
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
|
||||
#endif
|
||||
|
||||
class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
|
||||
public:
|
||||
MarlinSerial(LPC_UART_TypeDef *UARTx) : HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE>(UARTx) { }
|
||||
|
||||
@@ -121,7 +121,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
||||
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
||||
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \
|
||||
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||
|| ANY_RX(1, LCD_SDSS_PIN, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||
#error "Serial port pins (1) conflict with LCD pins!"
|
||||
#endif
|
||||
#endif
|
||||
@@ -211,8 +211,8 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#error "SCL0 overlaps with Encoder Button!"
|
||||
#elif IS_SCL0(SD_SS_PIN)
|
||||
#error "SCL0 overlaps with SD_SS_PIN!"
|
||||
#elif IS_SCL0(LCD_SDSS)
|
||||
#error "SCL0 overlaps with LCD_SDSS!"
|
||||
#elif IS_SCL0(LCD_SDSS_PIN)
|
||||
#error "SCL0 overlaps with LCD_SDSS_PIN!"
|
||||
#endif
|
||||
#undef PIN_IS_SDA0
|
||||
#undef IS_SCL0
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
//#define SD_SCK_PIN P0_07
|
||||
//#define SD_MISO_PIN P0_08
|
||||
//#define SD_MOSI_PIN P0_09
|
||||
//#define SD_SS_PIN P0_06
|
||||
|
||||
// External SD
|
||||
#ifndef SD_SCK_PIN
|
||||
@@ -44,10 +43,3 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN P0_18
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN P1_23
|
||||
#endif
|
||||
#if !defined(SDSS) || SDSS == P_NC // gets defaulted in pins.h
|
||||
#undef SDSS
|
||||
#define SDSS SD_SS_PIN
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ if pioutil.is_pio_build():
|
||||
#
|
||||
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
||||
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
||||
import subprocess,string
|
||||
import subprocess, string
|
||||
from ctypes import windll
|
||||
from pathlib import PureWindowsPath
|
||||
|
||||
|
||||
@@ -71,37 +71,10 @@ extern MSerialT serial_stream_2;
|
||||
extern MSerialT serial_stream_3;
|
||||
|
||||
#define _MSERIAL(X) serial_stream_##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3. Please update your configuration."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if WITHIN(MMU_SERIAL_PORT, 0, 3)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be from 0 to 3. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3. Please update your configuration."
|
||||
#endif
|
||||
#endif
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
// ------------------------
|
||||
// Interrupts
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
//#define SD_SCK_PIN P0_07
|
||||
//#define SD_MISO_PIN P0_08
|
||||
//#define SD_MOSI_PIN P0_09
|
||||
//#define SD_SS_PIN P0_06
|
||||
|
||||
// External SD
|
||||
#ifndef SD_SCK_PIN
|
||||
@@ -44,9 +43,3 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 52
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN 53
|
||||
#endif
|
||||
#ifndef SDSS
|
||||
#define SDSS SD_SS_PIN
|
||||
#endif
|
||||
|
||||
@@ -59,11 +59,8 @@ void MarlinHAL::init() {
|
||||
constexpr int cpuFreq = F_CPU;
|
||||
UNUSED(cpuFreq);
|
||||
|
||||
#undef SDSS
|
||||
#define SDSS 2
|
||||
#define PIN_EXISTS_(P1,P2) (defined(P1##P2) && P1##P2 >= 0)
|
||||
#if HAS_MEDIA && DISABLED(SDIO_SUPPORT) && PIN_EXISTS_(SDSS,)
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#if HAS_MEDIA && DISABLED(SDIO_SUPPORT) && PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SD_SS_PIN inactive before any other SPI users start up
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(LED)
|
||||
|
||||
@@ -35,73 +35,16 @@
|
||||
#include "fastio.h"
|
||||
//#include "Servo.h"
|
||||
#include "watchdog.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT, 0, 6)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 6)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 6)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
#if MMU2_SERIAL_PORT == -1
|
||||
#define MMU2_SERIAL MSerial0
|
||||
#elif WITHIN(MMU2_SERIAL_PORT, 0, 6)
|
||||
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||
#else
|
||||
#error "MMU2_SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL MSerial0
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 6)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#if HAS_DGUS_LCD
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
|
||||
@@ -29,24 +29,22 @@
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||
extern USBSerialType USBSerial;
|
||||
|
||||
#define Serial0 Serial
|
||||
#define _DECLARE_SERIAL(X) \
|
||||
typedef ForwardSerial1Class<decltype(Serial##X)> DefaultSerial##X; \
|
||||
extern DefaultSerial##X MSerial##X
|
||||
#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X)
|
||||
|
||||
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||
extern USBSerialType USBSerial;
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 6
|
||||
#define USB_SERIAL_PORT(...) MSerial0
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
// #define MYSERIAL1 USBSerial this is already done in the HAL
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
|
||||
Binary file not shown.
@@ -28,7 +28,7 @@
|
||||
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
|
||||
//#endif
|
||||
|
||||
#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)
|
||||
#if ENABLED(SDCARD_EEPROM_EMULATION) && !HAS_MEDIA
|
||||
#undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
|
||||
#if USE_FALLBACK_EEPROM
|
||||
#warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
class Sd2CardUSBMscHandler : public USBMscHandler {
|
||||
public:
|
||||
DiskIODriver* diskIODriver() {
|
||||
#if ENABLED(MULTI_VOLUME)
|
||||
#if HAS_MULTI_VOLUME
|
||||
#if SHARED_VOLUME_IS(SD_ONBOARD)
|
||||
return &card.media_driver_sdcard;
|
||||
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
|
||||
|
||||
@@ -112,7 +112,7 @@ uint8_t get_pin_mode(const pin_t Ard_num) {
|
||||
|
||||
}
|
||||
|
||||
bool GET_PINMODE(const pin_t Ard_num) {
|
||||
bool getValidPinMode(const pin_t Ard_num) {
|
||||
const uint8_t pin_mode = get_pin_mode(Ard_num);
|
||||
return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT; // assume all alt definitions are PWM
|
||||
}
|
||||
@@ -122,7 +122,7 @@ int8_t digital_pin_to_analog_pin(pin_t Ard_num) {
|
||||
return (Ard_num >= 0 && Ard_num < NUM_ANALOG_INPUTS) ? Ard_num : -1;
|
||||
}
|
||||
|
||||
bool IS_ANALOG(const pin_t Ard_num) {
|
||||
bool isAnalogPin(const pin_t Ard_num) {
|
||||
return digital_pin_to_analog_pin(Ard_num) != -1;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ bool is_digital(const pin_t x) {
|
||||
return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
|
||||
}
|
||||
|
||||
void print_port(const pin_t Ard_num) {
|
||||
void printPinPort(const pin_t Ard_num) {
|
||||
SERIAL_ECHOPGM("Pin: ");
|
||||
SERIAL_ECHO(Ard_num);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ bool pwm_status(const pin_t Ard_num) {
|
||||
return get_pin_mode(Ard_num) == MODE_PIN_ALT;
|
||||
}
|
||||
|
||||
void pwm_details(const pin_t Ard_num) {
|
||||
void printPinPWM(const pin_t Ard_num) {
|
||||
if (PWM_PIN(Ard_num)) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void MarlinHAL::init() {
|
||||
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||
#endif
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerialUSB;
|
||||
|
||||
// Serial ports
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
|
||||
@@ -51,43 +51,10 @@ extern DefaultSerial3 MSerial1;
|
||||
#define _MSERIAL(X) __MSERIAL(X)
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
||||
#if WITHIN(SERIAL_PORT, 0, 1)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#elif SERIAL_PORT == -1
|
||||
#define MYSERIAL1 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if WITHIN(SERIAL_PORT_2, 0, 1)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT)
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if WITHIN(MMU_SERIAL_PORT, 0, 1)
|
||||
#define MMU_SERIAL MSERIAL(SERIAL_PORT)
|
||||
#elif MMU_SERIAL_PORT == -1
|
||||
#define MMU_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, 0, 1)
|
||||
#define LCD_SERIAL MSERIAL(SERIAL_PORT)
|
||||
#elif LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be -1 (Native USB only)."
|
||||
#endif
|
||||
#endif
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 1
|
||||
#define USB_SERIAL_PORT(...) MSerialUSB
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
|
||||
@@ -45,10 +45,3 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 37
|
||||
#endif
|
||||
#ifndef SDSS
|
||||
#define SDSS 18
|
||||
#endif
|
||||
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN SDSS
|
||||
#endif
|
||||
|
||||
@@ -669,7 +669,7 @@ void MarlinHAL::init() {
|
||||
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||
#endif
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -34,72 +34,7 @@
|
||||
|
||||
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
||||
#include "MarlinSerial_AGCM4.h"
|
||||
|
||||
// Serial ports
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||
typedef ForwardSerial1Class< decltype(Serial4) > DefaultSerial5;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
extern DefaultSerial2 MSerial1;
|
||||
extern DefaultSerial3 MSerial2;
|
||||
extern DefaultSerial4 MSerial3;
|
||||
extern DefaultSerial5 MSerial4;
|
||||
|
||||
#define __MSERIAL(X) MSerial##X
|
||||
#define _MSERIAL(X) __MSERIAL(X)
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 3)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if MMU_SERIAL_PORT == -1
|
||||
#define MMU_SERIAL MSerial0
|
||||
#elif WITHIN(MMU_SERIAL_PORT, 0, 3)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL MSerial0
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // ADAFRUIT_GRAND_CENTRAL_M4
|
||||
#endif
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
|
||||
@@ -32,3 +32,24 @@ typedef Serial1Class<Uart> UartT;
|
||||
extern UartT Serial2;
|
||||
extern UartT Serial3;
|
||||
extern UartT Serial4;
|
||||
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4;
|
||||
typedef ForwardSerial1Class< decltype(Serial4) > DefaultSerial5;
|
||||
|
||||
extern DefaultSerial1 MSerial0;
|
||||
extern DefaultSerial2 MSerial1;
|
||||
extern DefaultSerial3 MSerial2;
|
||||
extern DefaultSerial4 MSerial3;
|
||||
extern DefaultSerial5 MSerial4;
|
||||
|
||||
#define __MSERIAL(X) MSerial##X
|
||||
#define _MSERIAL(X) __MSERIAL(X)
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#define USB_SERIAL_PORT(...) MSerial0
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
@@ -46,14 +46,9 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN 51
|
||||
#endif
|
||||
#ifndef SDSS
|
||||
#define SDSS 53
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#error "Unsupported board!"
|
||||
|
||||
#endif
|
||||
|
||||
#define SD_SS_PIN SDSS
|
||||
|
||||
@@ -69,8 +69,8 @@ void MarlinHAL::init() {
|
||||
constexpr int cpuFreq = F_CPU;
|
||||
UNUSED(cpuFreq);
|
||||
|
||||
#if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && (defined(SDSS) && SDSS != -1)
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && PIN_EXISTS(SD_SS)
|
||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(LED)
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "temp_soc.h"
|
||||
#include "fastio.h"
|
||||
#include "Servo.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
@@ -43,87 +42,11 @@
|
||||
#define CPU_ST7920_DELAY_2 40
|
||||
#define CPU_ST7920_DELAY_3 340
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerialUSB;
|
||||
#endif
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if WITHIN(SERIAL_PORT, 1, 9)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#elif !defined(USBCON)
|
||||
#error "SERIAL_PORT must be from 1 to 9."
|
||||
#elif SERIAL_PORT == -1
|
||||
#define MYSERIAL1 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if WITHIN(SERIAL_PORT_2, 1, 9)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#elif !defined(USBCON)
|
||||
#error "SERIAL_PORT_2 must be from 1 to 9."
|
||||
#elif SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 1 to 9, or -1 for Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if WITHIN(SERIAL_PORT_3, 1, 9)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#elif !defined(USBCON)
|
||||
#error "SERIAL_PORT_3 must be from 1 to 9."
|
||||
#elif SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 MSerialUSB
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 1 to 9, or -1 for Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if WITHIN(MMU_SERIAL_PORT, 1, 9)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#elif !defined(USBCON)
|
||||
#error "MMU_SERIAL_PORT must be from 1 to 9."
|
||||
#elif MMU_SERIAL_PORT == -1
|
||||
#define MMU_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "MMU_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, 1, 9)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#elif !defined(USBCON)
|
||||
#error "LCD_SERIAL_PORT must be from 1 to 9."
|
||||
#elif LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL MSerialUSB
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
|
||||
#endif
|
||||
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RS485_SERIAL_PORT
|
||||
#if WITHIN(RS485_SERIAL_PORT, 1, 9)
|
||||
#define RS485_SERIAL MSERIAL(RS485_SERIAL_PORT)
|
||||
#else
|
||||
#error "RS485_SERIAL_PORT must be from 1 to 9."
|
||||
#endif
|
||||
#endif
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
/**
|
||||
* TODO: review this to return 1 for pins that are not analog input
|
||||
|
||||
@@ -37,7 +37,17 @@
|
||||
#include "HardwareSerial.h"
|
||||
#include "uart.h"
|
||||
|
||||
// USART/UART PIN MAPPING FOR STM32F0/F1/F2/F4/F7
|
||||
// Prevent selection of LPUART1 on STM32H7xx
|
||||
#if defined(STM32H7xx) && (PIN_SERIAL1_TX == PA_9)
|
||||
#undef PIN_SERIAL1_TX
|
||||
#define PIN_SERIAL1_TX PA_9_ALT1
|
||||
#endif
|
||||
#if defined(STM32H7xx) && (PIN_SERIAL1_RX == PA_10)
|
||||
#undef PIN_SERIAL1_RX
|
||||
#define PIN_SERIAL1_RX PA_10_ALT1
|
||||
#endif
|
||||
|
||||
// USART/UART pin mapping for STM32F0/F1/F2/F4/F7/H7
|
||||
#ifndef PIN_SERIAL1_TX
|
||||
#define PIN_SERIAL1_TX PA9
|
||||
#endif
|
||||
@@ -75,46 +85,6 @@
|
||||
#define PIN_SERIAL6_RX PC7
|
||||
#endif
|
||||
|
||||
// TODO: Get from include file
|
||||
|
||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx)
|
||||
|
||||
#define RCC_AHB1Periph_DMA1 ((uint32_t)0x00200000)
|
||||
#define RCC_AHB1Periph_DMA2 ((uint32_t)0x00400000)
|
||||
|
||||
void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState) {
|
||||
// Check the parameters
|
||||
assert_param(IS_RCC_AHB1_CLOCK_PERIPH(RCC_AHB1Periph));
|
||||
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
if (NewState != DISABLE)
|
||||
RCC->AHB1ENR |= RCC_AHB1Periph;
|
||||
else
|
||||
RCC->AHB1ENR &= ~RCC_AHB1Periph;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ANY(STM32F0xx, STM32F1xx)
|
||||
|
||||
#define RCC_AHBPeriph_DMA1 ((uint32_t)0x00000001)
|
||||
#define RCC_AHBPeriph_DMA2 ((uint32_t)0x00000002)
|
||||
|
||||
void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) {
|
||||
/* Check the parameters */
|
||||
assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState != DISABLE)
|
||||
RCC->AHBENR |= RCC_AHBPeriph;
|
||||
else
|
||||
RCC->AHBENR &= ~RCC_AHBPeriph;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// END OF TODO------------------------------------------------------
|
||||
|
||||
// SerialEvent functions are weak, so when the user doesn't define them,
|
||||
// the linker just sets their address to 0 (which is checked below).
|
||||
#ifdef USING_HW_SERIAL1
|
||||
@@ -161,11 +131,12 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
setRx(PIN_SERIAL1_RX);
|
||||
setTx(PIN_SERIAL1_TX);
|
||||
_uart_index = 0;
|
||||
#ifdef DMA2_Stream2
|
||||
RX_DMA = { USART1, RCC_AHB1Periph_DMA2, 4, DMA2_Stream2 };
|
||||
|
||||
#ifdef DMA2_Stream2 // F2 / F4 / F7 / H7
|
||||
RX_DMA = { USART1, 2, DMA2_Stream2 }; // USART, DMA controller no., DMA stream
|
||||
#endif
|
||||
#ifdef DMA1_Channel5
|
||||
RX_DMA = { USART1, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel5 };
|
||||
#ifdef DMA1_Channel5 // F0 / F1
|
||||
RX_DMA = { USART1, 1, DMA1_Channel5 }; // USART, DMA controller no., DMA channel
|
||||
#endif
|
||||
}
|
||||
else if (peripheral == USART2) {
|
||||
@@ -173,10 +144,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
setTx(PIN_SERIAL2_TX);
|
||||
_uart_index = 1;
|
||||
#ifdef DMA1_Stream5
|
||||
RX_DMA = { USART2, RCC_AHB1Periph_DMA1, 4, DMA1_Stream5 };
|
||||
RX_DMA = { USART2, 1, DMA1_Stream5 };
|
||||
#endif
|
||||
#ifdef DMA1_Channel6
|
||||
RX_DMA = { USART2, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel6 };
|
||||
RX_DMA = { USART2, 1, DMA1_Channel6 };
|
||||
#endif
|
||||
}
|
||||
else if (peripheral == USART3) {
|
||||
@@ -184,17 +155,17 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
setTx(PIN_SERIAL3_TX);
|
||||
_uart_index = 2;
|
||||
#ifdef DMA1_Stream1
|
||||
RX_DMA = { USART3, RCC_AHB1Periph_DMA1, 4, DMA1_Stream1 };
|
||||
RX_DMA = { USART3, 1, DMA1_Stream1 };
|
||||
#endif
|
||||
#ifdef DMA1_Channel3 // F0 has no support for UART3, requires system remapping
|
||||
RX_DMA = { USART3, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel3 };
|
||||
RX_DMA = { USART3, 1, DMA1_Channel3 };
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USART4 // Only F2 / F4 / F7
|
||||
else if (peripheral == USART4) {
|
||||
#ifdef DMA1_Stream2
|
||||
RX_DMA = { USART4, RCC_AHB1Periph_DMA1, 4, DMA1_Stream2 };
|
||||
RX_DMA = { USART4, 1, DMA1_Stream2 };
|
||||
#endif
|
||||
setRx(PIN_SERIAL4_RX);
|
||||
setTx(PIN_SERIAL4_TX);
|
||||
@@ -205,10 +176,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
#ifdef UART4
|
||||
else if (peripheral == UART4) {
|
||||
#ifdef DMA1_Stream2
|
||||
RX_DMA = { UART4, RCC_AHB1Periph_DMA1, 4, DMA1_Stream2 };
|
||||
RX_DMA = { UART4, 1, DMA1_Stream2 };
|
||||
#endif
|
||||
#ifdef DMA2_Channel3 // STM32F0xx has only 3 UARTs
|
||||
RX_DMA = { UART4, RCC_AHBPeriph_DMA2, DMA2, DMA2_Channel3 };
|
||||
RX_DMA = { UART4, 2, DMA2_Channel3 };
|
||||
#endif
|
||||
setRx(PIN_SERIAL4_RX);
|
||||
setTx(PIN_SERIAL4_TX);
|
||||
@@ -216,10 +187,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UART5 // Only F2 / F4 / F7
|
||||
#ifdef UART5 // Only F2 / F4 / F7 / H7
|
||||
else if (peripheral == UART5) {
|
||||
#ifdef DMA1_Stream0
|
||||
RX_DMA = { UART5, RCC_AHB1Periph_DMA1, 4, DMA1_Stream0 };
|
||||
RX_DMA = { UART5, 1, DMA1_Stream0 };
|
||||
#endif
|
||||
setRx(PIN_SERIAL5_RX);
|
||||
setTx(PIN_SERIAL5_TX);
|
||||
@@ -227,10 +198,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USART6 // Only F2 / F4 / F7
|
||||
#ifdef USART6 // Only F2 / F4 / F7 / H7
|
||||
else if (peripheral == USART6) {
|
||||
#ifdef DMA2_Stream1
|
||||
RX_DMA = { USART6, RCC_AHB1Periph_DMA2, 4, DMA2_Stream1 };
|
||||
RX_DMA = { USART6, 2, DMA2_Stream1 };
|
||||
#endif
|
||||
setRx(PIN_SERIAL6_RX);
|
||||
setTx(PIN_SERIAL6_TX);
|
||||
@@ -271,14 +242,34 @@ void HAL_HardwareSerial::init(PinName _rx, PinName _tx) {
|
||||
* @param obj : pointer to serial_t structure
|
||||
* @retval last character received
|
||||
*/
|
||||
int HAL_HardwareSerial::_tx_complete_irq(serial_t *obj) {
|
||||
// If interrupts are enabled, there must be more data in the output buffer. Send the next byte
|
||||
obj->tx_tail = (obj->tx_tail + 1) % TX_BUFFER_SIZE;
|
||||
|
||||
if (obj->tx_head == obj->tx_tail) return -1;
|
||||
#if DISABLED(STM32H7xx)
|
||||
|
||||
return 0;
|
||||
}
|
||||
int HAL_HardwareSerial::_tx_complete_irq(serial_t *obj) {
|
||||
// If interrupts are enabled, there must be more data in the output buffer. Send the next byte
|
||||
obj->tx_tail = (obj->tx_tail + 1) % TX_BUFFER_SIZE;
|
||||
if (obj->tx_head == obj->tx_tail)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // STM32H7xx, has different uart_attach_tx_callback
|
||||
|
||||
int HAL_HardwareSerial::_tx_complete_irq(serial_t *obj) {
|
||||
// If interrupts are enabled, there must be more data in the output buffer. Send the next byte
|
||||
obj->tx_tail = (obj->tx_tail + obj->tx_size) % TX_BUFFER_SIZE;
|
||||
|
||||
if (obj->tx_head != obj->tx_tail) {
|
||||
size_t remaining_data = (TX_BUFFER_SIZE + obj->tx_head - obj->tx_tail) % TX_BUFFER_SIZE;
|
||||
obj->tx_size = min(remaining_data, (size_t)(TX_BUFFER_SIZE - obj->tx_tail));
|
||||
uart_attach_tx_callback(obj, _tx_complete_irq, obj->tx_size);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -340,7 +331,7 @@ void HAL_HardwareSerial::update_rx_head() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx)
|
||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx, STM32H7xx)
|
||||
_serial.rx_head = RX_BUFFER_SIZE - RX_DMA.dma_streamRX->NDTR;
|
||||
#endif
|
||||
|
||||
@@ -352,18 +343,22 @@ void HAL_HardwareSerial::update_rx_head() {
|
||||
|
||||
int HAL_HardwareSerial::available() {
|
||||
update_rx_head();
|
||||
|
||||
return ((unsigned int)(RX_BUFFER_SIZE + _serial.rx_head - _serial.rx_tail)) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
int HAL_HardwareSerial::peek() {
|
||||
update_rx_head();
|
||||
if (_serial.rx_head == _serial.rx_tail) return -1;
|
||||
if (_serial.rx_head == _serial.rx_tail)
|
||||
return -1;
|
||||
|
||||
return _serial.rx_buff[_serial.rx_tail];
|
||||
}
|
||||
|
||||
int HAL_HardwareSerial::read() {
|
||||
update_rx_head();
|
||||
if (_serial.rx_head == _serial.rx_tail) return -1; // No chars if the head isn't ahead of the tail
|
||||
if (_serial.rx_head == _serial.rx_tail)
|
||||
return -1; // No chars if the head isn't ahead of the tail
|
||||
|
||||
unsigned char c = _serial.rx_buff[_serial.rx_tail];
|
||||
_serial.rx_tail = (rx_buffer_index_t)(_serial.rx_tail + 1) % RX_BUFFER_SIZE;
|
||||
@@ -380,8 +375,18 @@ size_t HAL_HardwareSerial::write(uint8_t c) { // Interrupt based wri
|
||||
_serial.tx_buff[_serial.tx_head] = c;
|
||||
_serial.tx_head = i;
|
||||
|
||||
if (!serial_tx_active(&_serial))
|
||||
uart_attach_tx_callback(&_serial, _tx_complete_irq); // Write next byte, launch interrupt
|
||||
#ifdef STM32H7xx // Support STM32H7xx with different uart_attach_tx_callback
|
||||
if ((!serial_tx_active(&_serial)) && (_serial.tx_head != _serial.tx_tail)) {
|
||||
size_t remaining_data = (TX_BUFFER_SIZE + _serial.tx_head -_serial.tx_tail) % TX_BUFFER_SIZE;
|
||||
_serial.tx_size = min(remaining_data, (size_t)(TX_BUFFER_SIZE - _serial.tx_tail));
|
||||
uart_attach_tx_callback(&_serial, _tx_complete_irq, _serial.tx_size);
|
||||
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (!serial_tx_active(&_serial))
|
||||
uart_attach_tx_callback(&_serial, _tx_complete_irq); // Write next byte, launch interrupt
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -390,57 +395,132 @@ void HAL_HardwareSerial::flush() {
|
||||
while ((_serial.tx_head != _serial.tx_tail)) { /* nada */ } // nop, the interrupt handler will free up space for us
|
||||
}
|
||||
|
||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx)
|
||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx, STM32H7xx)
|
||||
|
||||
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
||||
RCC_AHB1PeriphClockCmd(RX_DMA.dma_rcc, ENABLE); // Enable DMA clock
|
||||
|
||||
#ifdef STM32F7xx
|
||||
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->RDR); // RX peripheral receive address (usart) F7
|
||||
if (RX_DMA.DMA_ID == 1)
|
||||
__HAL_RCC_DMA1_CLK_ENABLE(); // Enable DMA1 clock
|
||||
else
|
||||
__HAL_RCC_DMA2_CLK_ENABLE(); // Enable DMA2 clock
|
||||
|
||||
// Reset DMA, wait if needed to complete the running process
|
||||
RX_DMA.dma_streamRX->CR = 0; // DMA stream clear/disable
|
||||
while (RX_DMA.dma_streamRX->CR & DMA_SxCR_EN) { /* just wait for DMA to complete */ }
|
||||
|
||||
// UART clear/disable
|
||||
RX_DMA.uart->CR1 = 0;
|
||||
|
||||
// Configure DMA
|
||||
#if ANY(STM32F7xx, STM32H7xx) // F7 and H7 use RDR (Receive Data Register)
|
||||
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->RDR); // DMA stream Peripheral Address Register = USART Data Register
|
||||
#else
|
||||
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->DR); // RX peripheral address (usart) F2 / F4
|
||||
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->DR); // DMA stream Peripheral Address Register = USART Data Register
|
||||
#endif
|
||||
RX_DMA.dma_streamRX->M0AR = (uint32_t)_serial.rx_buff; // RX destination address (memory)
|
||||
RX_DMA.dma_streamRX->NDTR = RX_BUFFER_SIZE; // RX buffer size
|
||||
|
||||
RX_DMA.dma_streamRX->CR = (RX_DMA.dma_channel << 25); // RX channel selection, set to 0 all the other CR bits
|
||||
RX_DMA.dma_streamRX->M0AR = (uint32_t)_serial.rx_buff; // DMA stream Memory 0 Adress Register = RX buffer address
|
||||
RX_DMA.dma_streamRX->NDTR = RX_BUFFER_SIZE; // DMA stream Number of Data Transfer Register
|
||||
|
||||
RX_DMA.dma_streamRX->CR |= (3 << 16); // RX priority level: Very High
|
||||
#if DISABLED(STM32H7xx) // Select channel via CR register
|
||||
|
||||
//RX_DMA.dma_streamRX->CR &= ~(3 << 13); // RX memory data size: 8 bit
|
||||
//RX_DMA.dma_streamRX->CR &= ~(3 << 11); // RX peripheral data size: 8 bit
|
||||
RX_DMA.dma_streamRX->CR |= (1 << 10); // RX memory increment mode
|
||||
//RX_DMA.dma_streamRX->CR &= ~(1 << 9); // RX peripheral no increment mode
|
||||
RX_DMA.dma_streamRX->CR |= (1 << 8); // RX circular mode enabled
|
||||
//RX_DMA.dma_streamRX->CR &= ~(1 << 6); // RX data transfer direction: Peripheral-to-memory
|
||||
RX_DMA.uart->CR3 |= (1 << 6); // Enable DMA receiver (DMAR)
|
||||
RX_DMA.dma_streamRX->CR |= (1 << 0); // RX enable DMA
|
||||
RX_DMA.dma_streamRX->CR = 4 << DMA_SxCR_CHSEL_Pos; // DMA stream Channel Selection, always use channel 4
|
||||
|
||||
#else // STM32H7xx, select channel with DMAMUX1, channel DMA1 is channel DMAMUX, channel DMA2 is channel DMAMUX + 8
|
||||
|
||||
if (RX_DMA.uart == USART1) DMAMUX1_Channel10->CCR |= DMA_REQUEST_USART1_RX; // DMA2, Stream 2
|
||||
if (RX_DMA.uart == USART2) DMAMUX1_Channel5->CCR |= DMA_REQUEST_USART2_RX; // DMA1, Stream 5
|
||||
if (RX_DMA.uart == USART3) DMAMUX1_Channel1->CCR |= DMA_REQUEST_USART3_RX; // DMA1, Stream 1
|
||||
#ifdef UART4
|
||||
if (RX_DMA.uart == UART4) DMAMUX1_Channel2->CCR |= DMA_REQUEST_UART4_RX; // DMA1, Stream 2
|
||||
#endif
|
||||
#ifdef USART4
|
||||
if (RX_DMA.uart == USART4) DMAMUX1_Channel2->CCR |= DMA_REQUEST_USART4_RX; // DMA1, Stream 2
|
||||
#endif
|
||||
#ifdef UART5
|
||||
if (RX_DMA.uart == UART5) DMAMUX1_Channel0->CCR |= DMA_REQUEST_UART5_RX; // DMA1, Stream 0
|
||||
#endif
|
||||
#ifdef USART6
|
||||
if (RX_DMA.uart == USART6) DMAMUX1_Channel9->CCR |= DMA_REQUEST_USART6_RX; // DMA2, Stream 1
|
||||
#endif
|
||||
|
||||
#endif // !STM32H7xx
|
||||
|
||||
// Configure DMA
|
||||
//RX_DMA.dma_streamRX->CR |= DMA_MBURST_SINGLE; // DMA stream Memory Burst transfer: single transfer = 0b00
|
||||
//RX_DMA.dma_streamRX->CR |= DMA_PBURST_SINGLE; // DMA stream Peripheral Burst transfer: single transfer = 0b00
|
||||
|
||||
#if ENABLED(STM32H7xx)
|
||||
RX_DMA.dma_streamRX->CR |= DMA_SxCR_TRBUFF; // DMA stream Transfer handle bufferable (required for UART/USART)
|
||||
#endif
|
||||
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_CT; // DMA stream Current Target (only in double buffer mode)
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_DBM; // DMA stream Double Buffer Mode
|
||||
//RX_DMA.dma_streamRX->CR |= DMA_PRIORITY_LOW; // DMA stream Priority Level Low = 0b00
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_PINCOS; // DMA stream Peripheral Increment Offset Size
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_MSIZE; // DMA stream Memory data Size: 8 bit = 0b00
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_PSIZE; // DMA stream Peripheral data Size: 8 bit = 0b00
|
||||
RX_DMA.dma_streamRX->CR |= DMA_SxCR_MINC; // DMA stream Memory Increment enable
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_PINC; // DMA stream Peripheral increment
|
||||
RX_DMA.dma_streamRX->CR |= DMA_SxCR_CIRC; // DMA stream Circular mode enable
|
||||
//RX_DMA.dma_streamRX->CR |= DMA_PERIPH_TO_MEMORY; // DMA stream transfer Direction: Peripheral-to-memory = b00
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_PFCTRL; // DMA stream Peripheral Flow Controller: DMA = 0
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_TCIE; // DMA stream Transfer Complete Interrupt
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_HTIE; // DMA stream Half Transfer Interrupt
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_TEIE; // DMA stream Transfer Error Interrupt
|
||||
//RX_DMA.dma_streamRX->CR &= ~DMA_SxCR_DMEIE; // DMA stream Direct Mode Error Interrupt
|
||||
RX_DMA.dma_streamRX->CR |= DMA_SxCR_EN; // DMA stream Enable
|
||||
|
||||
// Configure UART/USART
|
||||
RX_DMA.uart->CR3 |= USART_CR3_DMAR; // UART DMA Receiver
|
||||
RX_DMA.uart->CR1 |= USART_CR1_TE; // UART Transmitter Enable
|
||||
RX_DMA.uart->CR1 |= USART_CR1_RE; // UART Receiver Enable
|
||||
RX_DMA.uart->CR1 |= USART_CR1_UE; // UART Enable
|
||||
}
|
||||
|
||||
#endif // STM32F2xx || STM32F4xx || STM32F7xx
|
||||
#endif // STM32F2xx || STM32F4xx || STM32F7xx || STM32H7xx
|
||||
|
||||
#if ANY(STM32F0xx, STM32F1xx)
|
||||
|
||||
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
||||
RCC_AHBPeriphClockCmd(RX_DMA.dma_rcc, ENABLE); // enable DMA clock
|
||||
|
||||
RX_DMA.dma_channelRX->CPAR = (uint32_t)(&RX_DMA.uart->DR); // RX peripheral address (usart)
|
||||
RX_DMA.dma_channelRX->CMAR = (uint32_t)_serial.rx_buff; // RX destination address (memory)
|
||||
RX_DMA.dma_channelRX->CNDTR = RX_BUFFER_SIZE; // RX buffer size
|
||||
if (RX_DMA.DMA_ID == 1)
|
||||
__HAL_RCC_DMA1_CLK_ENABLE(); // enable DMA1 clock
|
||||
else
|
||||
__HAL_RCC_DMA2_CLK_ENABLE(); // enable DMA2 clock
|
||||
|
||||
RX_DMA.dma_channelRX->CCR = 0; // RX channel selection, set to 0 all the other CR bits
|
||||
RX_DMA.dma_channelRX->CCR &= ~USART_CR1_UE; // DMA stream clear/disable
|
||||
while (RX_DMA.dma_channelRX->CCR & DMA_CCR_EN) { /* just wait for DMA to complete */ }
|
||||
|
||||
RX_DMA.dma_channelRX->CCR |= (3<<12); // RX priority level: Very High
|
||||
// Clear/disable UART and DMA
|
||||
RX_DMA.uart->CR1 = 0; // UART clear CR1, disable DMA
|
||||
|
||||
//RX_DMA.dma_channelRX->CCR &= ~(1<<10); // RX memory data size: 8 bit
|
||||
//RX_DMA.dma_channelRX->CCR &= ~(1<<8); // RX peripheral data size: 8 bit
|
||||
RX_DMA.dma_channelRX->CCR |= (1<<7); // RX memory increment mode
|
||||
//RX_DMA.dma_channelRX->CCR &= ~(1<<6); // RX peripheral no increment mode
|
||||
RX_DMA.dma_channelRX->CCR |= (1<<5); // RX circular mode enabled
|
||||
//RX_DMA.dma_channelRX->CCR &= ~(1<<4); // RX data transfer direction: Peripheral-to-memory
|
||||
// Configure DMA
|
||||
|
||||
RX_DMA.uart->CR3 |= (1<<6); // enable DMA receiver (DMAR)
|
||||
RX_DMA.dma_channelRX->CCR |= (1<<0); // RX enable DMA
|
||||
#ifdef STM32F0xx
|
||||
RX_DMA.dma_channelRX->CPAR = (uint32_t)(&RX_DMA.uart->RDR); // DMA channel Peripheral Address Register = USART Data Register
|
||||
#else
|
||||
RX_DMA.dma_channelRX->CPAR = (uint32_t)(&RX_DMA.uart->DR); // DMA channel Peripheral Address Register = USART Data Register
|
||||
#endif
|
||||
|
||||
RX_DMA.dma_channelRX->CMAR = (uint32_t)_serial.rx_buff; // DMA channel Memory Address Register
|
||||
RX_DMA.dma_channelRX->CNDTR = RX_BUFFER_SIZE; // DMA channel Number of Data Transfer Register
|
||||
//RX_DMA.dma_channelRX->CCR |= (0b00 << DMA_CCR_PL_Pos); // DMA channel Priority Level: Low = 0b00
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_MSIZE; // DMA channel Data Size: 8 bit = 0
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_PSIZE; // DMA channel Peripheral data size: 8 bit = 0
|
||||
RX_DMA.dma_channelRX->CCR |= DMA_CCR_MINC; // DMA channel Memory Increment enable
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_PINC; // DMA channel Peripheral Increment disable
|
||||
RX_DMA.dma_channelRX->CCR |= DMA_CCR_CIRC; // DMA channel Circular mode enable
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_DIR; // DMA channel Data Transfer direction: 0=Read peripheral, 1=Read memory
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_TEIE; // DMA channel Transfer Error Interrupt
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_HTIE; // DMA channel Half Transfer Interrupt
|
||||
//RX_DMA.dma_channelRX->CCR &= ~DMA_CCR_TCIE; // DMA channel Transfer Complete Interrupt
|
||||
RX_DMA.dma_channelRX->CCR |= DMA_CCR_EN; // DMA channel enable
|
||||
|
||||
// Configure UART/USART
|
||||
RX_DMA.uart->CR3 |= USART_CR3_DMAR; // UART DMA Receiver enabled
|
||||
RX_DMA.uart->CR1 |= USART_CR1_TE; // UART Transmitter Enable
|
||||
RX_DMA.uart->CR1 |= USART_CR1_RE; // UART Receiver Enable
|
||||
RX_DMA.uart->CR1 |= USART_CR1_UE; // UART Enable
|
||||
}
|
||||
|
||||
#endif // STM32F0xx || STM32F1xx
|
||||
|
||||
@@ -38,12 +38,10 @@
|
||||
|
||||
typedef struct {
|
||||
USART_TypeDef * uart;
|
||||
uint32_t dma_rcc;
|
||||
uint32_t DMA_ID; // DMA1=1; DM2=2; BDMA=3
|
||||
#if ANY(STM32F0xx, STM32F1xx) // F0 / F1
|
||||
DMA_TypeDef * dma_controller;
|
||||
DMA_Channel_TypeDef * dma_channelRX;
|
||||
#else // F2 / F4 / F7
|
||||
uint32_t dma_channel;
|
||||
#else // F2 / F4 / F7 / H7
|
||||
DMA_Stream_TypeDef * dma_streamRX;
|
||||
#endif
|
||||
} DMA_CFG;
|
||||
|
||||
@@ -33,6 +33,21 @@
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerialUSB;
|
||||
#define USB_SERIAL_PORT(...) MSerialUSB
|
||||
#endif
|
||||
|
||||
#define SERIAL_INDEX_MIN 1
|
||||
#define SERIAL_INDEX_MAX 9
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_DMA)
|
||||
|
||||
struct MarlinSerial : public HAL_HardwareSerial {
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#define FLASH_SECTOR (FLASH_SECTOR_TOTAL - 1)
|
||||
#endif
|
||||
#ifndef FLASH_UNIT_SIZE
|
||||
#define FLASH_UNIT_SIZE 0x20000 // 128kB
|
||||
#define FLASH_UNIT_SIZE 0x20000 // 128K
|
||||
#endif
|
||||
|
||||
#ifndef FLASH_ADDRESS_START
|
||||
@@ -74,13 +74,13 @@
|
||||
#define EEPROM_SLOTS ((FLASH_UNIT_SIZE) / (MARLIN_EEPROM_SIZE))
|
||||
#define SLOT_ADDRESS(slot) (FLASH_ADDRESS_START + (slot * (MARLIN_EEPROM_SIZE)))
|
||||
|
||||
#define UNLOCK_FLASH() if (!flash_unlocked) { \
|
||||
HAL_FLASH_Unlock(); \
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | \
|
||||
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); \
|
||||
flash_unlocked = true; \
|
||||
}
|
||||
#define LOCK_FLASH() if (flash_unlocked) { HAL_FLASH_Lock(); flash_unlocked = false; }
|
||||
#ifdef STM32H7xx
|
||||
#define FLASHWORD_SIZE 32U // STM32H7xx a FLASHWORD is 32 bytes (256 bits)
|
||||
#define FLASH_FLAGS_TO_CLEAR (FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGSERR)
|
||||
#else
|
||||
#define FLASHWORD_SIZE 4U // STM32F4xx a FLASHWORD is 4 bytes sizeof(uint32_t)
|
||||
#define FLASH_FLAGS_TO_CLEAR (FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR)
|
||||
#endif
|
||||
|
||||
#define EMPTY_UINT32 ((uint32_t)-1)
|
||||
#define EMPTY_UINT8 ((uint8_t)-1)
|
||||
@@ -88,7 +88,7 @@
|
||||
static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0};
|
||||
static int current_slot = -1;
|
||||
|
||||
static_assert(0 == MARLIN_EEPROM_SIZE % 4, "MARLIN_EEPROM_SIZE must be a multiple of 4"); // Ensure copying as uint32_t is safe
|
||||
static_assert(0 == MARLIN_EEPROM_SIZE % FLASHWORD_SIZE, "MARLIN_EEPROM_SIZE must be a multiple of the FLASHWORD size"); // Ensure copying as uint32_t is safe
|
||||
static_assert(0 == FLASH_UNIT_SIZE % MARLIN_EEPROM_SIZE, "MARLIN_EEPROM_SIZE must divide evenly into your FLASH_UNIT_SIZE");
|
||||
static_assert(FLASH_UNIT_SIZE >= MARLIN_EEPROM_SIZE, "FLASH_UNIT_SIZE must be greater than or equal to your MARLIN_EEPROM_SIZE");
|
||||
static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid");
|
||||
@@ -147,11 +147,15 @@ bool PersistentStore::access_start() {
|
||||
bool PersistentStore::access_finish() {
|
||||
|
||||
if (eeprom_data_written) {
|
||||
|
||||
#ifdef STM32F4xx
|
||||
// MCU may come up with flash error bits which prevent some flash operations.
|
||||
// Clear flags prior to flash operations to prevent errors.
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
|
||||
#endif
|
||||
#ifdef STM32H7xx
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGSERR);
|
||||
#endif
|
||||
|
||||
#if ENABLED(FLASH_EEPROM_LEVELING)
|
||||
|
||||
@@ -170,7 +174,12 @@ bool PersistentStore::access_finish() {
|
||||
EraseInitStruct.NbSectors = 1;
|
||||
|
||||
current_slot = EEPROM_SLOTS - 1;
|
||||
UNLOCK_FLASH();
|
||||
|
||||
if (!flash_unlocked) {
|
||||
HAL_FLASH_Unlock();
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAGS_TO_CLEAR);
|
||||
flash_unlocked = true;
|
||||
}
|
||||
|
||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
|
||||
hal.isr_off();
|
||||
@@ -181,26 +190,37 @@ bool PersistentStore::access_finish() {
|
||||
DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status);
|
||||
DEBUG_ECHOLNPGM("GetError=", HAL_FLASH_GetError());
|
||||
DEBUG_ECHOLNPGM("SectorError=", SectorError);
|
||||
LOCK_FLASH();
|
||||
if (flash_unlocked) {
|
||||
HAL_FLASH_Lock();
|
||||
flash_unlocked = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK_FLASH();
|
||||
if (!flash_unlocked) {
|
||||
HAL_FLASH_Unlock();
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAGS_TO_CLEAR);
|
||||
flash_unlocked = true;
|
||||
}
|
||||
|
||||
uint32_t offset = 0,
|
||||
address = SLOT_ADDRESS(current_slot),
|
||||
address_end = address + MARLIN_EEPROM_SIZE,
|
||||
data = 0;
|
||||
address_end = address + MARLIN_EEPROM_SIZE;
|
||||
|
||||
bool success = true;
|
||||
|
||||
while (address < address_end) {
|
||||
memcpy(&data, ram_eeprom + offset, sizeof(data));
|
||||
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
|
||||
#ifdef STM32H7xx
|
||||
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, address, uint32_t(ram_eeprom + offset));
|
||||
#else
|
||||
//memcpy(&data, ram_eeprom + offset, sizeof(data)); // IRON, IMPROVED
|
||||
//status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
|
||||
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, *(uint32_t*)(ram_eeprom + offset)); // IRON, OPTIMIZED
|
||||
#endif
|
||||
if (status == HAL_OK) {
|
||||
address += sizeof(uint32_t);
|
||||
offset += sizeof(uint32_t);
|
||||
address += FLASHWORD_SIZE;
|
||||
offset += FLASHWORD_SIZE;
|
||||
}
|
||||
else {
|
||||
DEBUG_ECHOLNPGM("HAL_FLASH_Program=", status);
|
||||
@@ -211,7 +231,10 @@ bool PersistentStore::access_finish() {
|
||||
}
|
||||
}
|
||||
|
||||
LOCK_FLASH();
|
||||
if (flash_unlocked) {
|
||||
HAL_FLASH_Lock();
|
||||
flash_unlocked = false;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
eeprom_data_written = false;
|
||||
|
||||
@@ -77,6 +77,7 @@ void FastIO_init(); // Must be called before using fast io macros
|
||||
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) //!< Input with Pull-up activation
|
||||
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) //!< Input with Pull-down activation
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
#define SET_OUTPUT_OD(IO) OUT_WRITE_OD(IO, LOW)
|
||||
#define SET_PWM(IO) _SET_MODE(IO, PWM)
|
||||
|
||||
#define IS_INPUT(IO)
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
|
||||
#endif
|
||||
|
||||
#if !defined(STM32F4xx) && ENABLED(FLASH_EEPROM_LEVELING)
|
||||
#error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4 hardware."
|
||||
#if NONE(STM32F4xx, STM32H7xx) && ENABLED(FLASH_EEPROM_LEVELING)
|
||||
#error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4/H7 hardware." // IRON
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
||||
@@ -58,7 +58,7 @@
|
||||
* Check for common serial pin conflicts
|
||||
*/
|
||||
#define _CHECK_SERIAL_PIN(N) (( \
|
||||
BTN_EN1 == N || BTN_EN2 == N ||DOGLCD_CS == N || HEATER_BED_PIN == N || FAN0_PIN == N || \
|
||||
BTN_EN1 == N || BTN_EN2 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN0_PIN == N || \
|
||||
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N || \
|
||||
Y_STEP_PIN == N || Y_ENABLE_PIN == N || E0_ENABLE_PIN == N || POWER_LOSS_PIN == N \
|
||||
))
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
class Sd2CardUSBMscHandler : public USBMscHandler {
|
||||
public:
|
||||
DiskIODriver* diskIODriver() {
|
||||
#if ENABLED(MULTI_VOLUME)
|
||||
#if HAS_MULTI_VOLUME
|
||||
#if SHARED_VOLUME_IS(SD_ONBOARD)
|
||||
return &card.media_driver_sdcard;
|
||||
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
|
||||
|
||||
@@ -33,6 +33,3 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN PIN_SPI_MOSI
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN PIN_SPI_SS
|
||||
#endif
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#include "msc_sd.h"
|
||||
#endif
|
||||
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
@@ -64,95 +62,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
#if HAS_SD_HOST_DRIVE
|
||||
#define UsbSerial MarlinCompositeSerial
|
||||
#else
|
||||
#define UsbSerial MSerial0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if ANY(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
#define NUM_UARTS 5
|
||||
#else
|
||||
#define NUM_UARTS 3
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 UsbSerial
|
||||
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#define MYSERIAL1 MSERIAL(1) // dummy port
|
||||
static_assert(false, "SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 UsbSerial
|
||||
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#define MYSERIAL2 MSERIAL(1) // dummy port
|
||||
static_assert(false, "SERIAL_PORT_2 must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 UsbSerial
|
||||
#elif WITHIN(SERIAL_PORT_3, 1, NUM_UARTS)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#define MYSERIAL3 MSERIAL(1) // dummy port
|
||||
static_assert(false, "SERIAL_PORT_3 must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if MMU_SERIAL_PORT == -1
|
||||
#define MMU_SERIAL UsbSerial
|
||||
#elif WITHIN(MMU_SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#else
|
||||
#define MMU_SERIAL MSERIAL(1) // dummy port
|
||||
static_assert(false, "MMU_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL UsbSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#define LCD_SERIAL MSERIAL(1) // dummy port
|
||||
static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#if ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RS485_SERIAL_PORT
|
||||
#if RS485_SERIAL_PORT == -1
|
||||
#define RS485_SERIAL UsbSerial
|
||||
#elif WITHIN(RS485_SERIAL_PORT, 1, NUM_UARTS)
|
||||
#define RS485_SERIAL MSERIAL(RS485_SERIAL_PORT)
|
||||
#else
|
||||
#define RS485_SERIAL MSERIAL(1) // dummy port
|
||||
static_assert(false, "RS485_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ".")
|
||||
#endif
|
||||
#endif
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
/**
|
||||
* TODO: review this to return 1 for pins that are not analog input
|
||||
|
||||
@@ -28,6 +28,29 @@
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
#if HAS_SD_HOST_DRIVE
|
||||
#define UsbSerial MarlinCompositeSerial
|
||||
#else
|
||||
#define UsbSerial MSerial0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SERIAL_INDEX_MIN 1
|
||||
#if ANY(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||
#define SERIAL_INDEX_MAX 5
|
||||
#else
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#endif
|
||||
#define USB_SERIAL_PORT(...) UsbSerial
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
||||
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
#endif
|
||||
|
||||
// Increase priority of serial interrupts, to reduce overflow errors
|
||||
#define UART_IRQ_PRIO 1
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
// Store settings in the last two pages
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#define MARLIN_EEPROM_SIZE ((EEPROM_PAGE_SIZE) * 2)
|
||||
#define MARLIN_EEPROM_SIZE ((EEPROM_PAGE_SIZE) * 2UL)
|
||||
#endif
|
||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE - eeprom_exclude_size; }
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, GPIO_INPUT_PU)
|
||||
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, GPIO_INPUT_PD)
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
#define SET_OUTPUT_OD(IO) OUT_WRITE_OD(IO, LOW)
|
||||
#define SET_PWM(IO) pinMode(IO, PWM) // do{ gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP); timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, TIMER_PWM); }while(0)
|
||||
#define SET_PWM_OD(IO) pinMode(IO, PWM_OPEN_DRAIN)
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@
|
||||
#ifndef SD_MOSI_PIN
|
||||
#define SD_MOSI_PIN PA7
|
||||
#endif
|
||||
#ifndef SD_SS_PIN
|
||||
#define SD_SS_PIN PA4
|
||||
#endif
|
||||
#undef SDSS
|
||||
#define SDSS SD_SS_PIN
|
||||
|
||||
#ifndef SPI_DEVICE
|
||||
#define SPI_DEVICE 1
|
||||
|
||||
@@ -37,10 +37,20 @@
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
#if WITHIN(SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT);
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3."
|
||||
#endif
|
||||
#if defined(SERIAL_PORT_2) && WITHIN(SERIAL_PORT_2, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_2);
|
||||
#endif
|
||||
#if defined(SERIAL_PORT_3) && WITHIN(SERIAL_PORT_3, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_3);
|
||||
#endif
|
||||
#if defined(MMU_SERIAL_PORT) && WITHIN(MMU_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(MMU_SERIAL_PORT);
|
||||
#endif
|
||||
#if defined(LCD_SERIAL_PORT) && WITHIN(LCD_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(LCD_SERIAL_PORT);
|
||||
#endif
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
|
||||
@@ -64,17 +64,10 @@
|
||||
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||
extern USBSerialType USBSerial;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#endif
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#define USB_SERIAL_PORT(...) USBSerial
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
|
||||
@@ -24,4 +24,3 @@
|
||||
#define SD_SCK_PIN 13
|
||||
#define SD_MISO_PIN 12
|
||||
#define SD_MOSI_PIN 11
|
||||
#define SD_SS_PIN 20 // SDSS // A.28, A.29, B.21, C.26, C.29
|
||||
|
||||
@@ -37,10 +37,21 @@
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
#if WITHIN(SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT);
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_PORT_2) && WITHIN(SERIAL_PORT_2, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_2);
|
||||
#endif
|
||||
#if defined(SERIAL_PORT_3) && WITHIN(SERIAL_PORT_3, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_3);
|
||||
#endif
|
||||
#if defined(MMU_SERIAL_PORT) && WITHIN(MMU_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(MMU_SERIAL_PORT);
|
||||
#endif
|
||||
#if defined(LCD_SERIAL_PORT) && WITHIN(LCD_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(LCD_SERIAL_PORT);
|
||||
#endif
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
// ------------------------
|
||||
|
||||
@@ -70,17 +70,10 @@
|
||||
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||
extern USBSerialType USBSerial;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#endif
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 3
|
||||
#define USB_SERIAL_PORT(...) USBSerial
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
|
||||
@@ -28,4 +28,3 @@
|
||||
#define SD_SCK_PIN 13
|
||||
#define SD_MISO_PIN 12
|
||||
#define SD_MOSI_PIN 11
|
||||
#define SD_SS_PIN 20 // SDSS // A.28, A.29, B.21, C.26, C.29
|
||||
|
||||
@@ -39,18 +39,20 @@
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 8)
|
||||
#if WITHIN(SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT);
|
||||
#endif
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if WITHIN(SERIAL_PORT_2, 0, 8)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_2);
|
||||
#endif
|
||||
#if defined(SERIAL_PORT_2) && WITHIN(SERIAL_PORT_2, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_2);
|
||||
#endif
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if WITHIN(SERIAL_PORT_3, 0, 8)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_3);
|
||||
#endif
|
||||
#if defined(SERIAL_PORT_3) && WITHIN(SERIAL_PORT_3, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(SERIAL_PORT_3);
|
||||
#endif
|
||||
#if defined(MMU_SERIAL_PORT) && WITHIN(MMU_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(MMU_SERIAL_PORT);
|
||||
#endif
|
||||
#if defined(LCD_SERIAL_PORT) && WITHIN(LCD_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
IMPLEMENT_SERIAL(LCD_SERIAL_PORT);
|
||||
#endif
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
@@ -202,18 +204,13 @@ uint16_t MarlinHAL::adc_value() {
|
||||
// Free Memory Accessor
|
||||
// ------------------------
|
||||
|
||||
#define __bss_end _ebss
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
extern void* __brkval;
|
||||
// Reference for Teensy 4.x: https://forum.pjrc.com/index.php?threads/how-to-display-free-ram.33443/#post-275013
|
||||
extern unsigned long _heap_end;
|
||||
extern char *__brkval;
|
||||
|
||||
// Doesn't work on Teensy 4.x
|
||||
uint32_t freeMemory() {
|
||||
uint32_t free_memory;
|
||||
free_memory = ((uint32_t)&free_memory) - (((uint32_t)__brkval) ?: ((uint32_t)&__bss_end));
|
||||
return free_memory;
|
||||
return (char *)&_heap_end - __brkval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
#undef PSTR
|
||||
#define PSTR(str) ({static const char *data = (str); &data[0];})
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
@@ -76,41 +78,11 @@
|
||||
typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
|
||||
extern USBSerialType USBSerial;
|
||||
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
#define MYSERIAL1 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT, 0, 8)
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from 0 to 8, or -1 for Native USB."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if SERIAL_PORT_2 == -1
|
||||
#define MYSERIAL2 USBSerial
|
||||
#elif SERIAL_PORT_2 == -2
|
||||
#define MYSERIAL2 ethernet.telnetClient
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 8)
|
||||
DECLARE_SERIAL(SERIAL_PORT_2);
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 8, or -1 for Native USB, or -2 for Ethernet."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 8)
|
||||
DECLARE_SERIAL(SERIAL_PORT_3);
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 8, or -1 for Native USB."
|
||||
#endif
|
||||
#endif
|
||||
#define SERIAL_INDEX_MIN 0
|
||||
#define SERIAL_INDEX_MAX 8
|
||||
#define USB_SERIAL_PORT(...) USBSerial
|
||||
#define ETH_SERIAL_PORT(...) ethernet.telnetClient
|
||||
#include "../shared/serial_ports.h"
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
@@ -221,11 +193,15 @@ public:
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
/**
|
||||
* Set the PWM output frequency. This may affect multiple pins, though
|
||||
* Teensy 4.x provides many timers affecting only a single pin.
|
||||
* See: https://www.pjrc.com/teensy/td_pulse.html
|
||||
*/
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __IMXRT1062__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "HAL.h"
|
||||
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size /*=255*/, const bool invert) {
|
||||
|
||||
uint32_t bits = 1;
|
||||
uint16_t value = _MIN(v, v_size);
|
||||
|
||||
if (invert) value = v_size - value;
|
||||
|
||||
// Choose scale as smallest power of 2 which holds v_size.
|
||||
uint32_t scale = 1;
|
||||
while (scale < v_size) {
|
||||
bits++;
|
||||
scale *= 2;
|
||||
}
|
||||
|
||||
uint32_t scaled_val = scale * value / v_size;
|
||||
|
||||
uint32_t prior = analogWriteResolution(bits);
|
||||
analogWrite(pin, scaled_val);
|
||||
analogWriteResolution(prior);
|
||||
}
|
||||
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
analogWriteFrequency(pin, f_desired);
|
||||
}
|
||||
|
||||
#endif // __IMXRT1062__
|
||||
@@ -33,10 +33,6 @@
|
||||
#error "EMERGENCY_PARSER is not yet implemented for Teensy 4.0/4.1. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for Teensy 4.0/4.1."
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SW_SERIAL
|
||||
#error "TMC220x Software Serial is not supported for Teensy 4.0/4.1."
|
||||
#endif
|
||||
@@ -44,3 +40,19 @@
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not yet supported for Teensy 4.0/4.1."
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) || ENABLED(SERIAL_STATS_DROPPED_RX) || ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS) || ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
|
||||
#error "SERIAL_STATS_* features not supported on Teensy 4.0/4.1."
|
||||
#endif
|
||||
|
||||
#if ENABLED(BAUD_RATE_GCODE) && SERIAL_PORT_2 == -2
|
||||
#error "BAUD_RATE_GCODE cannot be enabled when using the Ethernet serial port."
|
||||
#endif
|
||||
|
||||
#if ENABLED(SPINDLE_LASER_USE_PWM) && !ENABLED(SILENCE_TEENSY_SPINDLE_LASER_WARNING)
|
||||
#warning "SPINDLE_LASER_USE_PWM is untested on Teensy 4.0/4.1, see https://www.pjrc.com/teensy/td_pulse.html for details on frequencies, and resolution. #define SILENCE_TEENSY_SPINDLE_LASER_WARNING to silence warning."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN) && FAST_PWM_FAN_FREQUENCY == 1000U
|
||||
#warning "FAST_PWM_FAN_FREQUENCY has been left as default, see https://www.pjrc.com/teensy/td_pulse.html and consider raising it to reduce noise."
|
||||
#endif
|
||||
|
||||
@@ -28,4 +28,3 @@
|
||||
#define SD_SCK_PIN 13
|
||||
#define SD_MISO_PIN 12
|
||||
#define SD_MOSI_PIN 11
|
||||
#define SD_SS_PIN 20 // SDSS // A.28, A.29, B.21, C.26, C.29
|
||||
|
||||
@@ -174,6 +174,9 @@ void calibrate_delay_loop();
|
||||
|
||||
// Delay in microseconds
|
||||
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
|
||||
|
||||
#define DELAY_CYCLES_VAR DELAY_CYCLES
|
||||
|
||||
#else
|
||||
|
||||
#error "Unsupported MCU architecture"
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* serial_ports.h - Define Marlin serial port macros and optionally declare ports
|
||||
*
|
||||
* This header defines one or more of the serial ports...
|
||||
* - MYSERIAL1/2/3 ..... for host devices
|
||||
* - MMU_SERIAL ........ for Multi-Material color changers
|
||||
* - LCD_SERIAL ........ for serial LCDs
|
||||
* - RS485_SERIAL ...... for CAN bus devices
|
||||
*
|
||||
* Before including this header define the following macros:
|
||||
* - SERIAL_INDEX_MIN, SERIAL_INDEX_MAX to provide the valid range of serial port indexes.
|
||||
* - _MSERIAL(X) and MSERIAL(X) to provide the instance name of Serial Port X. (Default: MSerial##X)
|
||||
* - EP_SERIAL_PORT(X) to provide the instance name of Emergency Parser serial port X (if it is special).
|
||||
* - USB_SERIAL_PORT(X) to provide the instance name of the USB serial port (if any).
|
||||
* - ETH_SERIAL_PORT(X) to provide the instance name of the Ethernet serial port (if any).
|
||||
* - DECLARE_SERIAL(X) to declare standard a serial port with the given index.
|
||||
*/
|
||||
|
||||
#ifndef _MSERIAL
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#endif
|
||||
#ifndef MSERIAL
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
#endif
|
||||
|
||||
#define INDEX_RANGE_MSG " must be from " STRINGIFY(SERIAL_INDEX_MIN) " to " STRINGIFY(SERIAL_INDEX_MAX)
|
||||
#if defined(USB_SERIAL_PORT) && defined(ETH_SERIAL_PORT)
|
||||
#define MORE_INDEXES_MSG ", -1 for Native USB, or -2 for Ethernet"
|
||||
#elif defined(USB_SERIAL_PORT)
|
||||
#define MORE_INDEXES_MSG ", or -1 for Native USB"
|
||||
#elif defined(ETH_SERIAL_PORT)
|
||||
#define MORE_INDEXES_MSG ", or -2 for Ethernet"
|
||||
#else
|
||||
#define MORE_INDEXES_MSG
|
||||
#endif
|
||||
|
||||
//
|
||||
// SERIAL_PORT => MYSERIAL1
|
||||
//
|
||||
|
||||
#if defined(EP_SERIAL_PORT) && ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL1 EP_SERIAL_PORT(1)
|
||||
#elif WITHIN(SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#endif
|
||||
#elif SERIAL_PORT == -1 && defined(USB_SERIAL_PORT)
|
||||
#define MYSERIAL1 USB_SERIAL_PORT(1)
|
||||
#elif SERIAL_PORT == -2 && defined(ETH_SERIAL_PORT)
|
||||
#define MYSERIAL1 ETH_SERIAL_PORT(1)
|
||||
#endif
|
||||
#ifndef MYSERIAL1
|
||||
static_assert(false, "SERIAL_PORT" INDEX_RANGE_MSG MORE_INDEXES_MSG ".");
|
||||
#define MYSERIAL1 _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
|
||||
//
|
||||
// SERIAL_PORT_2 => MYSERIAL2
|
||||
//
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if defined(EP_SERIAL_PORT) && ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL2 EP_SERIAL_PORT(2)
|
||||
#elif WITHIN(SERIAL_PORT_2, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(SERIAL_PORT_2);
|
||||
#endif
|
||||
#elif SERIAL_PORT_2 == -1 && defined(USB_SERIAL_PORT)
|
||||
#define MYSERIAL2 USB_SERIAL_PORT(2)
|
||||
#elif SERIAL_PORT_2 == -2 && defined(ETH_SERIAL_PORT)
|
||||
#define MYSERIAL2 ETH_SERIAL_PORT(2)
|
||||
#endif
|
||||
#ifndef MYSERIAL2
|
||||
static_assert(false, "SERIAL_PORT_2" INDEX_RANGE_MSG MORE_INDEXES_MSG ".");
|
||||
#define MYSERIAL2 _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// SERIAL_PORT_3 => MYSERIAL3
|
||||
//
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if defined(EP_SERIAL_PORT) && ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL3 EP_SERIAL_PORT(3)
|
||||
#elif WITHIN(SERIAL_PORT_3, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(SERIAL_PORT_3);
|
||||
#endif
|
||||
#elif SERIAL_PORT_3 == -1 && defined(USB_SERIAL_PORT)
|
||||
#define MYSERIAL3 USB_SERIAL_PORT(3)
|
||||
#elif SERIAL_PORT_3 == -2 && defined(ETH_SERIAL_PORT)
|
||||
#define MYSERIAL3 ETH_SERIAL_PORT(3)
|
||||
#endif
|
||||
#ifndef MYSERIAL3
|
||||
static_assert(false, "SERIAL_PORT_3" INDEX_RANGE_MSG MORE_INDEXES_MSG ".");
|
||||
#define MYSERIAL3 _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// MMU_SERIAL_PORT => MMU_SERIAL
|
||||
//
|
||||
|
||||
#ifdef MMU_SERIAL_PORT
|
||||
#if WITHIN(MMU_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define MMU_SERIAL MSERIAL(MMU_SERIAL_PORT)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(MMU_SERIAL_PORT);
|
||||
#endif
|
||||
#else
|
||||
static_assert(false, "MMU_SERIAL_PORT" INDEX_RANGE_MSG ".");
|
||||
#define MMU_SERIAL _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD_SERIAL_PORT => LCD_SERIAL
|
||||
//
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if WITHIN(LCD_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(LCD_SERIAL_PORT);
|
||||
#endif
|
||||
#else
|
||||
static_assert(false, "LCD_SERIAL_PORT" INDEX_RANGE_MSG ".");
|
||||
#define LCD_SERIAL _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// RS485_SERIAL_PORT => RS485_SERIAL
|
||||
//
|
||||
|
||||
#ifdef RS485_SERIAL_PORT
|
||||
#if WITHIN(RS485_SERIAL_PORT, SERIAL_INDEX_MIN, SERIAL_INDEX_MAX)
|
||||
#define RS485_SERIAL MSERIAL(RS485_SERIAL_PORT)
|
||||
#ifdef DECLARE_SERIAL
|
||||
DECLARE_SERIAL(RS485_SERIAL_PORT);
|
||||
#endif
|
||||
#else
|
||||
static_assert(false, "RS485_SERIAL_PORT" INDEX_RANGE_MSG ".");
|
||||
#define RS485_SERIAL _MSERIAL(1) // Dummy port
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef DECLARE_SERIAL
|
||||
#undef SERIAL_INDEX_MIN
|
||||
#undef SERIAL_INDEX_MAX
|
||||
#undef INDEX_RANGE_MSG
|
||||
@@ -271,6 +271,10 @@
|
||||
|
||||
PGMSTR(M112_KILL_STR, "M112 Shutdown");
|
||||
|
||||
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
|
||||
MString<64> machine_name;
|
||||
#endif
|
||||
|
||||
MarlinState marlin_state = MarlinState::MF_INITIALIZING;
|
||||
|
||||
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
|
||||
@@ -815,7 +819,7 @@ void idle(const bool no_stepper_sleep/*=false*/) {
|
||||
TERN_(HAS_MEDIA, card.manage_media());
|
||||
|
||||
// Handle USB Flash Drive insert / remove
|
||||
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());
|
||||
TERN_(HAS_USB_FLASH_DRIVE, card.diskIODriver()->idle());
|
||||
|
||||
// Announce Host Keepalive state (if any)
|
||||
TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
|
||||
@@ -1258,7 +1262,7 @@ void setup() {
|
||||
SETUP_RUN(runout.setup());
|
||||
#endif
|
||||
|
||||
#if HAS_TMC220x
|
||||
#if HAS_TMC_UART
|
||||
SETUP_RUN(tmc_serial_begin());
|
||||
#endif
|
||||
|
||||
@@ -1363,6 +1367,10 @@ void setup() {
|
||||
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
|
||||
// This also updates variables in the planner, elsewhere
|
||||
|
||||
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
|
||||
SETUP_RUN(ui.reset_status(false)); // machine_name Initialized by settings.load()
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_TARE)
|
||||
SETUP_RUN(probe.tare_init());
|
||||
#endif
|
||||
|
||||
@@ -41,6 +41,10 @@ inline void idle_no_sleep() { idle(true); }
|
||||
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);
|
||||
|
||||
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
|
||||
extern MString<64> machine_name;
|
||||
#endif
|
||||
|
||||
// Global State of the firmware
|
||||
enum class MarlinState : uint8_t {
|
||||
MF_INITIALIZING = 0,
|
||||
|
||||
+98
-80
@@ -318,7 +318,7 @@
|
||||
#define BOARD_ADSK 3101 // Arduino DUE Shield Kit (ADSK)
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M0+
|
||||
// STM32 ARM Cortex-M0/+
|
||||
//
|
||||
|
||||
#define BOARD_BTT_EBB42_V1_1 4000 // BigTreeTech EBB42 V1.1 (STM32G0B1CB)
|
||||
@@ -330,83 +330,91 @@
|
||||
#define BOARD_BTT_MANTA_M8P_V1_1 4006 // BigTreeTech Manta M8P V1.1 (STM32G0B1VE)
|
||||
#define BOARD_BTT_SKRAT_V1_0 4007 // BigTreeTech SKRat V1.0 (STM32G0B1VE)
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M0
|
||||
//
|
||||
|
||||
#define BOARD_MALYAN_M200_V2 4100 // STM32F070CB controller
|
||||
#define BOARD_MALYAN_M300 4101 // STM32F070-based delta
|
||||
#define BOARD_FLY_D5 4102 // FLY_D5 (STM32F072RB)
|
||||
#define BOARD_FLY_DP5 4103 // FLY_DP5 (STM32F072RB)
|
||||
#define BOARD_FLY_D7 4104 // FLY_D7 (STM32F072RB)
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_MALYAN_M200_V2 5000 // STM32F070CB controller
|
||||
#define BOARD_MALYAN_M300 5001 // STM32F070-based delta
|
||||
#define BOARD_STM32F103RE 5002 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_MALYAN_M200 5003 // STM32C8 Libmaple-based STM32F1 controller
|
||||
#define BOARD_STM3R_MINI 5004 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_GTM32_PRO_VB 5005 // STM32F103VE controller
|
||||
#define BOARD_GTM32_PRO_VD 5006 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI 5007 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI_A30 5008 // STM32F103VE controller
|
||||
#define BOARD_GTM32_REV_B 5009 // STM32F103VE controller
|
||||
#define BOARD_MORPHEUS 5010 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
|
||||
#define BOARD_CHITU3D 5011 // Chitu3D (STM32F103RE)
|
||||
#define BOARD_MKS_ROBIN 5012 // MKS Robin (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_MINI 5013 // MKS Robin Mini (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO 5014 // MKS Robin Nano (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V2 5015 // MKS Robin Nano V2 (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_LITE 5016 // MKS Robin Lite/Lite2 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_LITE3 5017 // MKS Robin Lite3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_PRO 5018 // MKS Robin Pro (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_E3 5019 // MKS Robin E3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3_V1_1 5020 // MKS Robin E3 V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D 5021 // MKS Robin E3D (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D_V1_1 5022 // MKS Robin E3D V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3P 5023 // MKS Robin E3P (STM32F103VE)
|
||||
#define BOARD_BTT_SKR_MINI_V1_1 5024 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_0 5025 // BigTreeTech SKR Mini E3 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_2 5026 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 5027 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 5028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 5029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 5030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
#define BOARD_JGAURORA_A5S_A1 5031 // JGAurora A5S A1 (STM32F103ZE)
|
||||
#define BOARD_FYSETC_AIO_II 5032 // FYSETC AIO_II (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH 5033 // FYSETC Cheetah (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH_V12 5034 // FYSETC Cheetah V1.2 (STM32F103RC)
|
||||
#define BOARD_LONGER3D_LK 5035 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE)
|
||||
#define BOARD_CCROBOT_MEEB_3DP 5036 // ccrobot-online.com MEEB_3DP (STM32F103RC)
|
||||
#define BOARD_CHITU3D_V5 5037 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V6 5038 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V9 5039 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE)
|
||||
#define BOARD_CREALITY_V4 5040 // Creality v4.x (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V422 5041 // Creality v4.2.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V423 5042 // Creality v4.2.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V425 5043 // Creality v4.2.5 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 5044 // Creality v4.2.7 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V4210 5045 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30
|
||||
#define BOARD_CREALITY_V431 5046 // Creality v4.3.1 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_A 5047 // Creality v4.3.1a (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_B 5048 // Creality v4.3.1b (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_C 5049 // Creality v4.3.1c (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_D 5050 // Creality v4.3.1d (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V452 5051 // Creality v4.5.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V453 5052 // Creality v4.5.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V521 5053 // Creality v5.2.1 (STM32F103VE) as found in the SV04
|
||||
#define BOARD_CREALITY_V24S1 5054 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) CR-FDM-v2.4.S1_v101 as found in the Ender-7
|
||||
#define BOARD_CREALITY_V24S1_301 5055 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) CR-FDM-v24S1_301 as found in the Ender-3 S1
|
||||
#define BOARD_CREALITY_V25S1 5056 // Creality v2.5.S1 (STM32F103RE) CR-FDM-v2.5.S1_100 as found in the CR-10 Smart Pro
|
||||
#define BOARD_TRIGORILLA_PRO 5057 // Trigorilla Pro (STM32F103ZE)
|
||||
#define BOARD_FLY_MINI 5058 // FLYmaker FLY MINI (STM32F103RC)
|
||||
#define BOARD_FLSUN_HISPEED 5059 // FLSUN HiSpeedV1 (STM32F103VE)
|
||||
#define BOARD_BEAST 5060 // STM32F103RE Libmaple-based controller
|
||||
#define BOARD_MINGDA_MPX_ARM_MINI 5061 // STM32F103ZE Mingda MD-16
|
||||
#define BOARD_ZONESTAR_ZM3E2 5062 // Zonestar ZM3E2 (STM32F103RC)
|
||||
#define BOARD_ZONESTAR_ZM3E4 5063 // Zonestar ZM3E4 V1 (STM32F103VC)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 5064 // Zonestar ZM3E4 V2 (STM32F103VC)
|
||||
#define BOARD_ERYONE_ERY32_MINI 5065 // Eryone Ery32 mini (STM32F103VE)
|
||||
#define BOARD_PANDA_PI_V29 5066 // Panda Pi V2.9 - Standalone (STM32F103RC)
|
||||
#define BOARD_SOVOL_V131 5067 // Sovol V1.3.1 (GD32F103RE)
|
||||
#define BOARD_TRIGORILLA_V006 5068 // Trigorilla V0.0.6 (GD32F103RE)
|
||||
#define BOARD_KEDI_CONTROLLER_V1_2 5069 // EDUTRONICS Kedi Controller V1.2 (STM32F103RC)
|
||||
#define BOARD_MD_D301 5070 // Mingda D2 DZ301 V1.0 (STM32F103ZE)
|
||||
#define BOARD_VOXELAB_AQUILA 5071 // Voxelab Aquila V1.0.0/V1.0.1 (GD32F103RC / N32G455RE / STM32F103RE)
|
||||
#define BOARD_SPRINGER_CONTROLLER 5072 // ORCA 3D SPRINGER Modular Controller (STM32F103VC)
|
||||
#define BOARD_STM32F103RE 5000 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_MALYAN_M200 5001 // STM32C8 Libmaple-based STM32F1 controller
|
||||
#define BOARD_STM3R_MINI 5002 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_GTM32_PRO_VB 5003 // STM32F103VE controller
|
||||
#define BOARD_GTM32_PRO_VD 5004 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI 5005 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI_A30 5006 // STM32F103VE controller
|
||||
#define BOARD_GTM32_REV_B 5007 // STM32F103VE controller
|
||||
#define BOARD_MORPHEUS 5008 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
|
||||
#define BOARD_CHITU3D 5009 // Chitu3D (STM32F103RE)
|
||||
#define BOARD_MKS_ROBIN 5010 // MKS Robin (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_MINI 5011 // MKS Robin Mini (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO 5012 // MKS Robin Nano (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V2 5013 // MKS Robin Nano V2 (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_LITE 5014 // MKS Robin Lite/Lite2 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_LITE3 5015 // MKS Robin Lite3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_PRO 5016 // MKS Robin Pro (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_E3 5017 // MKS Robin E3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3_V1_1 5018 // MKS Robin E3 V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D 5019 // MKS Robin E3D (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D_V1_1 5020 // MKS Robin E3D V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3P 5021 // MKS Robin E3P (STM32F103VE)
|
||||
#define BOARD_BTT_SKR_MINI_V1_1 5022 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_0 5023 // BigTreeTech SKR Mini E3 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_2 5024 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 5025 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 5026 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 5027 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 5028 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
#define BOARD_JGAURORA_A5S_A1 5029 // JGAurora A5S A1 (STM32F103ZE)
|
||||
#define BOARD_FYSETC_AIO_II 5030 // FYSETC AIO_II (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH 5031 // FYSETC Cheetah (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH_V12 5032 // FYSETC Cheetah V1.2 (STM32F103RC)
|
||||
#define BOARD_LONGER3D_LK 5033 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE)
|
||||
#define BOARD_CCROBOT_MEEB_3DP 5034 // ccrobot-online.com MEEB_3DP (STM32F103RC)
|
||||
#define BOARD_CHITU3D_V5 5035 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V6 5036 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V9 5037 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE)
|
||||
#define BOARD_CREALITY_V4 5038 // Creality v4.x (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V422 5039 // Creality v4.2.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V423 5040 // Creality v4.2.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V425 5041 // Creality v4.2.5 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 5042 // Creality v4.2.7 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V4210 5043 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30
|
||||
#define BOARD_CREALITY_V431 5044 // Creality v4.3.1 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_A 5045 // Creality v4.3.1a (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_B 5046 // Creality v4.3.1b (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_C 5047 // Creality v4.3.1c (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_D 5048 // Creality v4.3.1d (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V452 5049 // Creality v4.5.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V453 5050 // Creality v4.5.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V521 5051 // Creality v5.2.1 (STM32F103VE) as found in the SV04
|
||||
#define BOARD_CREALITY_V24S1 5052 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) CR-FDM-v2.4.S1_v101 as found in the Ender-7
|
||||
#define BOARD_CREALITY_V24S1_301 5053 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) CR-FDM-v24S1_301 as found in the Ender-3 S1
|
||||
#define BOARD_CREALITY_V25S1 5054 // Creality v2.5.S1 (STM32F103RE) CR-FDM-v2.5.S1_100 as found in the CR-10 Smart Pro
|
||||
#define BOARD_TRIGORILLA_PRO 5055 // Trigorilla Pro (STM32F103ZE)
|
||||
#define BOARD_FLY_MINI 5056 // FLYmaker FLY MINI (STM32F103RC)
|
||||
#define BOARD_FLSUN_HISPEED 5057 // FLSUN HiSpeedV1 (STM32F103VE)
|
||||
#define BOARD_BEAST 5058 // STM32F103RE Libmaple-based controller
|
||||
#define BOARD_MINGDA_MPX_ARM_MINI 5059 // STM32F103ZE Mingda MD-16
|
||||
#define BOARD_ZONESTAR_ZM3E2 5060 // Zonestar ZM3E2 (STM32F103RC)
|
||||
#define BOARD_ZONESTAR_ZM3E4 5061 // Zonestar ZM3E4 V1 (STM32F103VC)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 5062 // Zonestar ZM3E4 V2 (STM32F103VC)
|
||||
#define BOARD_ERYONE_ERY32_MINI 5063 // Eryone Ery32 mini (STM32F103VE)
|
||||
#define BOARD_PANDA_PI_V29 5064 // Panda Pi V2.9 - Standalone (STM32F103RC)
|
||||
#define BOARD_SOVOL_V131 5065 // Sovol V1.3.1 (GD32F103RE)
|
||||
#define BOARD_TRIGORILLA_V006 5066 // Trigorilla V0.0.6 (GD32F103RE)
|
||||
#define BOARD_KEDI_CONTROLLER_V1_2 5067 // EDUTRONICS Kedi Controller V1.2 (STM32F103RC)
|
||||
#define BOARD_MD_D301 5068 // Mingda D2 DZ301 V1.0 (STM32F103ZE)
|
||||
#define BOARD_VOXELAB_AQUILA 5069 // Voxelab Aquila V1.0.0/V1.0.1 (GD32F103RC / N32G455RE / STM32F103RE)
|
||||
#define BOARD_SPRINGER_CONTROLLER 5070 // ORCA 3D SPRINGER Modular Controller (STM32F103VC)
|
||||
|
||||
//
|
||||
// ARM Cortex-M4F
|
||||
@@ -457,12 +465,12 @@
|
||||
#define BOARD_FYSETC_CHEETAH_V30 5235 // FYSETC Cheetah V3.0 (STM32F446RC)
|
||||
#define BOARD_TH3D_EZBOARD_V2 5236 // TH3D EZBoard v2.0 (STM32F405RG)
|
||||
#define BOARD_OPULO_LUMEN_REV3 5237 // Opulo Lumen PnP Controller REV3 (STM32F407VE / STM32F407VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 5238 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE)
|
||||
#define BOARD_MKS_EAGLE 5239 // MKS Eagle (STM32F407VE)
|
||||
#define BOARD_ARTILLERY_RUBY 5240 // Artillery Ruby (STM32F401RC)
|
||||
#define BOARD_CREALITY_V24S1_301F4 5241 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4
|
||||
#define BOARD_CREALITY_CR4NTXXC10 5242 // Creality E3 Free-runs Silent Motherboard (STM32F401RET6)
|
||||
#define BOARD_OPULO_LUMEN_REV4 5243 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG)
|
||||
#define BOARD_OPULO_LUMEN_REV4 5238 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 5239 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE)
|
||||
#define BOARD_MKS_EAGLE 5240 // MKS Eagle (STM32F407VE)
|
||||
#define BOARD_ARTILLERY_RUBY 5241 // Artillery Ruby (STM32F401RC)
|
||||
#define BOARD_CREALITY_V24S1_301F4 5242 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4
|
||||
#define BOARD_CREALITY_CR4NTXXC10 5243 // Creality E3 Free-runs Silent Motherboard (STM32F401RET6)
|
||||
#define BOARD_FYSETC_SPIDER_KING407 5244 // FYSETC Spider King407 (STM32F407ZG)
|
||||
#define BOARD_MKS_SKIPR_V1 5245 // MKS SKIPR v1.0 all-in-one board (STM32F407VE)
|
||||
#define BOARD_TRONXY_CXY_446_V10 5246 // TRONXY CXY-446-V10-220413/CXY-V6-191121 (STM32F446ZE)
|
||||
@@ -472,6 +480,14 @@
|
||||
#define BOARD_MELLOW_FLY_E3_V2 5250 // Mellow Fly E3 V2 (STM32F407VG)
|
||||
#define BOARD_BLACKBEEZMINI_V1 5251 // BlackBeezMini V1 (STM32F401CCU6)
|
||||
#define BOARD_XTLW_CLIMBER_8TH 5252 // XTLW Climber-8th (STM32F407VGT6)
|
||||
#define BOARD_FLY_RRF_E3_V1 5253 // Fly RRF E3 V1.0 (STM32F407VG)
|
||||
#define BOARD_FLY_SUPER8 5254 // Fly SUPER8 (STM32F407ZGT6)
|
||||
#define BOARD_FLY_D8 5255 // FLY D8 (STM32F407VG)
|
||||
#define BOARD_FLY_CDY_V3 5256 // FLY CDY V3 (STM32F407VGT6)
|
||||
#define BOARD_ZNP_ROBIN_NANO 5257 // Elegoo Neptune 2 v1.2 board
|
||||
#define BOARD_ZNP_ROBIN_NANO_V1_3 5258 // Elegoo Neptune 2 v1.3 board
|
||||
#define BOARD_MKS_NEPTUNE_X 5259 // Elegoo Neptune X
|
||||
#define BOARD_MKS_NEPTUNE_3 5260 // Elegoo Neptune 3
|
||||
|
||||
//
|
||||
// Other ARM Cortex-M4
|
||||
@@ -495,6 +511,8 @@
|
||||
#define BOARD_BTT_KRAKEN_V1_0 6010 // BigTreeTech Kraken v1.0 (STM32H723ZG)
|
||||
#define BOARD_TEENSY41 6011 // Teensy 4.1
|
||||
#define BOARD_T41U5XBB 6012 // T41U5XBB Teensy 4.1 breakout board
|
||||
#define BOARD_FLY_D8_PRO 6013 // FLY_D8_PRO (STM32H723VG)
|
||||
#define BOARD_FLY_SUPER8_PRO 6014 // FLY SUPER8 PRO (STM32H723ZG)
|
||||
|
||||
//
|
||||
// Espressif ESP32 WiFi
|
||||
|
||||
@@ -188,3 +188,16 @@
|
||||
|| HAS_DRIVER(TMC5130_STANDALONE) || HAS_DRIVER(TMC5160_STANDALONE)
|
||||
#define HAS_DIAG_PINS 1
|
||||
#endif
|
||||
|
||||
// Hybrid Threshold ranges
|
||||
#define THRS_TMC2100 65535
|
||||
#define THRS_TMC2130 65535
|
||||
#define THRS_TMC2160 255
|
||||
#define THRS_TMC2208 255
|
||||
#define THRS_TMC2209 255
|
||||
#define THRS_TMC2660 65535
|
||||
#define THRS_TMC5130 65535
|
||||
#define THRS_TMC5160 65535
|
||||
|
||||
#define _DRIVER_THRS(V) CAT(THRS_, V)
|
||||
#define STEPPER_MAX_THRS(S) _DRIVER_THRS(S##_DRIVER_TYPE)
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
#undef MACHINE_NAME
|
||||
#define MACHINE_NAME DEFAULT_MACHINE_NAME
|
||||
#endif
|
||||
#define MACHINE_NAME_SUBST TERN(CONFIGURABLE_MACHINE_NAME, "$", MACHINE_NAME)
|
||||
|
||||
#define MARLIN_WEBSITE_URL "marlinfw.org"
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
#define CBI32(n,b) (n &= ~_BV32(b))
|
||||
#define TBI32(N,B) (N ^= _BV32(B))
|
||||
|
||||
// Macros for common maths operations
|
||||
#define cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);})
|
||||
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
|
||||
#define DEGREES(r) ((r)*180.0f/float(M_PI))
|
||||
@@ -93,6 +94,8 @@
|
||||
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
||||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||
|
||||
#define FLIP(X) (X = !(X))
|
||||
|
||||
// Macros to constrain values
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
||||
@@ -298,6 +298,9 @@ public:
|
||||
MString& clear() { return set(); }
|
||||
MString& eol() { return append('\n'); }
|
||||
MString& trunc(const int &i) { if (i <= SIZE) str[i] = '\0'; debug(F("trunc")); return *this; }
|
||||
MString& ltrim() { char *s = str; while (*s == ' ') ++s; if (s != str) strcpy(str, s); return *this; }
|
||||
MString& rtrim() { int s = length(); while (s && str[s - 1] == ' ') --s; str[s] = '\0'; return *this; }
|
||||
MString& trim() { return rtrim().ltrim(); }
|
||||
|
||||
// Truncate on a Unicode boundary
|
||||
MString& utrunc(const int &n=SIZE) {
|
||||
|
||||
@@ -180,6 +180,8 @@ template <class L, class R> struct IF<true, L, R> { typedef L type; };
|
||||
#define uvalue_t(V) typename IF<((V)>65535), uint32_t, typename IF<((V)>255), uint16_t, uint8_t>::type>::type
|
||||
#define value_t(V) typename IF<((V)>32767), int32_t, typename IF<((V)>127), int16_t, int8_t>::type>::type
|
||||
|
||||
class BitProxy;
|
||||
|
||||
// Define a template for a bit field of N bits, using the smallest type that can hold N bits
|
||||
template<size_t N, bool UseArray = (N > 64)>
|
||||
struct Flags;
|
||||
@@ -346,7 +348,7 @@ enum AxisEnum : uint8_t {
|
||||
#define LOOP_DISTINCT_E(VAR) for (uint8_t VAR = 0; VAR < DISTINCT_E; ++VAR)
|
||||
|
||||
//
|
||||
// feedRate_t is just a humble float
|
||||
// feedRate_t is just a humble float that can represent mm/s or mm/min
|
||||
//
|
||||
typedef float feedRate_t;
|
||||
|
||||
@@ -1018,8 +1020,6 @@ struct XYZEarray {
|
||||
FI XYZEval<T> operator[](const int n) const { return XYZval<T>(LOGICAL_AXIS_ARRAY(e[n], x[n], y[n], z[n], i[n], j[n], k[n], u[n], v[n], w[n])); }
|
||||
};
|
||||
|
||||
class AxisBits;
|
||||
|
||||
class AxisBits {
|
||||
public:
|
||||
typedef bits_t(NUM_AXIS_HEADS) el;
|
||||
|
||||
@@ -77,7 +77,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
|
||||
|
||||
// Get the corrected leveled / unleveled position
|
||||
planner.apply_modifiers(current_position, true); // Physical position with all modifiers
|
||||
planner.leveling_active ^= true; // Toggle leveling between apply and unapply
|
||||
FLIP(planner.leveling_active); // Toggle leveling between apply and unapply
|
||||
planner.unapply_modifiers(current_position, true); // Logical position with modifiers removed
|
||||
|
||||
sync_plan_position();
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
#include "../hilbert_curve.h"
|
||||
#endif
|
||||
|
||||
#if FT_MOTION_DISABLE_FOR_PROBING
|
||||
#include "../../../module/ft_motion.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define UBL_G29_P31
|
||||
@@ -297,12 +301,22 @@ G29_parameters_t unified_bed_leveling::param;
|
||||
|
||||
void unified_bed_leveling::G29() {
|
||||
|
||||
bool probe_deployed = false;
|
||||
#ifdef EVENT_GCODE_AFTER_G29
|
||||
bool probe_deployed = false;
|
||||
#define SET_PROBE_DEPLOYED(N) probe_deployed = N
|
||||
#else
|
||||
#define SET_PROBE_DEPLOYED(N)
|
||||
#endif
|
||||
|
||||
if (G29_parse_parameters()) return; // Abort on parameter error
|
||||
|
||||
const uint8_t p_val = parser.byteval('P');
|
||||
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
|
||||
|
||||
#if FT_MOTION_DISABLE_FOR_PROBING
|
||||
FTMotionDisableInScope FT_Disabler; // Disable Fixed-Time Motion for probing
|
||||
#endif
|
||||
|
||||
// Check for commands that require the printer to be homed
|
||||
if (may_move) {
|
||||
planner.synchronize();
|
||||
@@ -316,6 +330,11 @@ void unified_bed_leveling::G29() {
|
||||
#endif
|
||||
probe.use_probing_tool();
|
||||
|
||||
#ifdef EVENT_GCODE_BEFORE_G29
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Before G29 G-code: ", EVENT_GCODE_BEFORE_G29);
|
||||
gcode.process_subcommands_now(F(EVENT_GCODE_BEFORE_G29));
|
||||
#endif
|
||||
|
||||
// Position bed horizontally and Z probe vertically.
|
||||
#if HAS_SAFE_BED_LEVELING
|
||||
xyze_pos_t safe_position = current_position;
|
||||
@@ -430,7 +449,7 @@ void unified_bed_leveling::G29() {
|
||||
do_blocking_move_to_xy(0.5f * ((MESH_MIN_X) + (MESH_MAX_X)), 0.5f * ((MESH_MIN_Y) + (MESH_MAX_Y)));
|
||||
#endif
|
||||
report_current_position();
|
||||
probe_deployed = true;
|
||||
SET_PROBE_DEPLOYED(true);
|
||||
}
|
||||
|
||||
#endif // HAS_BED_PROBE
|
||||
@@ -465,7 +484,7 @@ void unified_bed_leveling::G29() {
|
||||
probe_entire_mesh(param.XY_pos, parser.seen_test('T'), parser.seen_test('E'), parser.seen_test('U'));
|
||||
|
||||
report_current_position();
|
||||
probe_deployed = true;
|
||||
SET_PROBE_DEPLOYED(true);
|
||||
} break;
|
||||
|
||||
#endif // HAS_BED_PROBE
|
||||
@@ -503,7 +522,7 @@ void unified_bed_leveling::G29() {
|
||||
SERIAL_ECHOLNPGM("?Error in Business Card measurement.");
|
||||
return;
|
||||
}
|
||||
probe_deployed = true;
|
||||
SET_PROBE_DEPLOYED(true);
|
||||
}
|
||||
|
||||
if (!position_is_reachable(param.XY_pos)) {
|
||||
@@ -681,13 +700,11 @@ void unified_bed_leveling::G29() {
|
||||
#endif
|
||||
|
||||
#ifdef EVENT_GCODE_AFTER_G29
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("After G29 G-code: ", EVENT_GCODE_AFTER_G29);
|
||||
if (probe_deployed) {
|
||||
planner.synchronize();
|
||||
gcode.process_subcommands_now(F(EVENT_GCODE_AFTER_G29));
|
||||
}
|
||||
#else
|
||||
UNUSED(probe_deployed);
|
||||
#endif
|
||||
|
||||
probe.use_probing_tool(false);
|
||||
@@ -1590,7 +1607,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
||||
}
|
||||
|
||||
if (abort_flag) break;
|
||||
zig_zag ^= true;
|
||||
FLIP(zig_zag);
|
||||
}
|
||||
}
|
||||
probe.stow();
|
||||
@@ -1778,14 +1795,14 @@ void unified_bed_leveling::smart_fill_mesh() {
|
||||
SERIAL_ECHOLNPGM("ubl_state_at_invocation :", ubl_state_at_invocation, "\nubl_state_recursion_chk :", ubl_state_recursion_chk);
|
||||
serial_delay(50);
|
||||
|
||||
SERIAL_ECHOLNPGM("Meshes go from ", hex_address((void*)settings.meshes_start_index()), " to ", hex_address((void*)settings.meshes_end_index()));
|
||||
SERIAL_ECHOLNPGM("Meshes go from ", _hex_word(settings.meshes_start_index()), " to ", _hex_word(settings.meshes_end_index()));
|
||||
serial_delay(50);
|
||||
|
||||
SERIAL_ECHOLNPGM("sizeof(unified_bed_leveling) : ", sizeof(unified_bed_leveling));
|
||||
SERIAL_ECHOLNPGM("z_value[][] size: ", sizeof(z_values));
|
||||
serial_delay(25);
|
||||
|
||||
SERIAL_ECHOLNPGM("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
|
||||
SERIAL_ECHOLNPGM("EEPROM free for UBL: ", _hex_word(settings.meshes_end_index() - settings.meshes_start_index()));
|
||||
serial_delay(50);
|
||||
|
||||
SERIAL_ECHOLNPGM("EEPROM can hold ", settings.calc_num_meshes(), " meshes.\n");
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
static bool enabled;
|
||||
static void enable() { enabled = true; }
|
||||
static void disable() { enabled = false; }
|
||||
static void toggle() { enabled = !enabled; }
|
||||
static void toggle() { FLIP(enabled); }
|
||||
|
||||
static uint8_t mode; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling
|
||||
static void set_mode(const uint8_t m) { mode = m; }
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
#if ENABLED(FLOWMETER_SAFETY)
|
||||
static bool flowfault; // Flag that the cooler is in a fault state
|
||||
static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low
|
||||
static void flowsafety_toggle() { flowsafety_enabled = !flowsafety_enabled; }
|
||||
static void flowsafety_toggle() { FLIP(flowsafety_enabled); }
|
||||
static bool check_flow_too_low() {
|
||||
const bool too_low = flowsafety_enabled && flowrate < (FLOWMETER_MIN_LITERS_PER_MINUTE);
|
||||
flowfault = too_low;
|
||||
|
||||
@@ -67,7 +67,7 @@ class FanCheck {
|
||||
static void compute_speed(uint16_t elapsedTime);
|
||||
static void print_fan_states();
|
||||
#if HAS_PWMFANCHECK
|
||||
static void toggle_measuring() { measuring = !measuring; }
|
||||
static void toggle_measuring() { FLIP(measuring); }
|
||||
static bool is_measuring() { return measuring; }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ void Max7219::register_setup() {
|
||||
}
|
||||
else
|
||||
sweepx -= MAX7219_X_LEDS * sweep_dir;
|
||||
patt_on ^= true;
|
||||
FLIP(patt_on);
|
||||
next_patt_ms += 100;
|
||||
if (++test_mode > 4) test_mode = 0;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
|
||||
Mixer mixer;
|
||||
|
||||
#ifdef MIXER_NORMALIZER_DEBUG
|
||||
#include "../core/serial.h"
|
||||
#endif
|
||||
|
||||
// Used up to Planner level
|
||||
uint_fast8_t Mixer::selected_vtool = 0;
|
||||
float Mixer::collector[MIXING_STEPPERS]; // mix proportion. 0.0 = off, otherwise <= COLOR_A_MASK.
|
||||
|
||||
@@ -47,7 +47,7 @@ void SpoolJoin::initStatus() {
|
||||
|
||||
void SpoolJoin::toggle() {
|
||||
// Toggle enabled value.
|
||||
enabled = !enabled;
|
||||
FLIP(enabled);
|
||||
|
||||
// Following Prusa's implementation let's save the value to the EEPROM
|
||||
// TODO: Move to settings.cpp
|
||||
|
||||
@@ -219,14 +219,14 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
|
||||
|
||||
while (wait_for_user) {
|
||||
impatient_beep(max_beep_count);
|
||||
#if ALL(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR)
|
||||
#if ALL(HAS_FILAMENT_SENSOR, FILAMENT_CHANGE_RESUME_ON_INSERT)
|
||||
#if MULTI_FILAMENT_SENSOR
|
||||
#define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break;
|
||||
#define _CASE_INSERTED(N) case N-1: if (!FILAMENT_IS_OUT(N)) wait_for_user = false; break;
|
||||
switch (active_extruder) {
|
||||
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED)
|
||||
}
|
||||
#else
|
||||
if (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) wait_for_user = false;
|
||||
if (!FILAMENT_IS_OUT()) wait_for_user = false;
|
||||
#endif
|
||||
#endif
|
||||
idle_no_sleep();
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#include "powerloss.h"
|
||||
#include "../core/macros.h"
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
#include "../lcd/extui/ui_api.h"
|
||||
@@ -60,7 +61,6 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0
|
||||
#include "../module/planner.h"
|
||||
#include "../module/printcounter.h"
|
||||
#include "../module/temperature.h"
|
||||
#include "../core/serial.h"
|
||||
|
||||
#if HOMING_Z_WITH_PROBE
|
||||
#include "../module/probe.h"
|
||||
@@ -99,7 +99,7 @@ PrintJobRecovery recovery;
|
||||
/**
|
||||
* Clear the recovery info
|
||||
*/
|
||||
void PrintJobRecovery::init() { memset(&info, 0, sizeof(info)); }
|
||||
void PrintJobRecovery::init() { info = {}; }
|
||||
|
||||
/**
|
||||
* Enable or disable then call changed()
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#define HAS_FILAMENT_SWITCH 1
|
||||
#endif
|
||||
|
||||
#define FILAMENT_IS_OUT(N...) (READ(FIL_RUNOUT##N##_PIN) == FIL_RUNOUT##N##_STATE)
|
||||
|
||||
typedef Flags<
|
||||
#if NUM_MOTION_SENSORS > NUM_RUNOUT_SENSORS
|
||||
NUM_MOTION_SENSORS
|
||||
|
||||
@@ -614,9 +614,10 @@
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // TMC2160 || TMC5160
|
||||
|
||||
#if HAS_TMC220x
|
||||
|
||||
static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
|
||||
switch (i) {
|
||||
case TMC_PWM_SCALE_SUM: SERIAL_ECHO(st.pwm_scale_sum()); break;
|
||||
@@ -664,7 +665,8 @@
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // HAS_TMC220x
|
||||
|
||||
#if HAS_DRIVER(TMC2660)
|
||||
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <TMCStepper.h>
|
||||
#include "../module/planner.h"
|
||||
|
||||
#define CHOPPER_DEFAULT_12V { 3, -1, 1 }
|
||||
#define CHOPPER_DEFAULT_12V { 3, -1, 1 } // { toff, hend, hstrt }
|
||||
#define CHOPPER_DEFAULT_19V { 4, 1, 1 }
|
||||
#define CHOPPER_DEFAULT_24V { 4, 2, 1 }
|
||||
#define CHOPPER_DEFAULT_36V { 5, 2, 4 }
|
||||
@@ -77,8 +77,8 @@ class TMCStorage {
|
||||
|
||||
struct {
|
||||
OPTCODE(HAS_STEALTHCHOP, bool stealthChop_enabled = false)
|
||||
OPTCODE(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0)
|
||||
OPTCODE(USE_SENSORLESS, int16_t homing_thrs = 0)
|
||||
OPTCODE(HYBRID_THRESHOLD, uint16_t hybrid_thrs = 0)
|
||||
OPTCODE(USE_SENSORLESS, int16_t homing_thrs = 0)
|
||||
} stored;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class TWIBus {
|
||||
private:
|
||||
/**
|
||||
* @brief Number of bytes on buffer
|
||||
* @description Number of bytes in the buffer waiting to be flushed to the bus
|
||||
* @details Number of bytes in the buffer waiting to be flushed to the bus
|
||||
*/
|
||||
uint8_t buffer_s = 0;
|
||||
|
||||
@@ -77,7 +77,7 @@ class TWIBus {
|
||||
public:
|
||||
/**
|
||||
* @brief Target device address
|
||||
* @description The target device address. Persists until changed.
|
||||
* @details The target device address. Persists until changed.
|
||||
*/
|
||||
uint8_t addr = 0;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
* 41 - Counter-Clockwise M4
|
||||
* 50 - Clockwise M5
|
||||
* 51 - Counter-Clockwise M5
|
||||
**/
|
||||
*/
|
||||
void GcodeSuite::G35() {
|
||||
|
||||
DEBUG_SECTION(log_G35, "G35", DEBUGGING(LEVELING));
|
||||
|
||||
@@ -43,40 +43,40 @@
|
||||
* P : Flag to put the probe at the given point
|
||||
*/
|
||||
void GcodeSuite::G42() {
|
||||
if (MOTION_CONDITIONS) {
|
||||
const bool hasI = parser.seenval('I');
|
||||
const int8_t ix = hasI ? parser.value_int() : 0;
|
||||
const bool hasJ = parser.seenval('J');
|
||||
const int8_t iy = hasJ ? parser.value_int() : 0;
|
||||
if (!MOTION_CONDITIONS) return;
|
||||
|
||||
if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
|
||||
SERIAL_ECHOLNPGM(STR_ERR_MESH_XY);
|
||||
return;
|
||||
}
|
||||
const bool hasI = parser.seenval('I');
|
||||
const int8_t ix = hasI ? parser.value_int() : 0;
|
||||
const bool hasJ = parser.seenval('J');
|
||||
const int8_t iy = hasJ ? parser.value_int() : 0;
|
||||
|
||||
// Move to current_position, as modified by I, J, P parameters
|
||||
destination = current_position;
|
||||
|
||||
if (hasI) destination.x = bedlevel.get_mesh_x(ix);
|
||||
if (hasJ) destination.y = bedlevel.get_mesh_y(iy);
|
||||
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
if (parser.seen_test('P')) {
|
||||
if (hasI) destination.x -= probe.offset_xy.x;
|
||||
if (hasJ) destination.y -= probe.offset_xy.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
const feedRate_t fval = parser.linearval('F'),
|
||||
fr_mm_s = MMM_TO_MMS(fval > 0 ? fval : 0.0f);
|
||||
|
||||
// SCARA kinematic has "safe" XY raw moves
|
||||
#if IS_SCARA
|
||||
prepare_internal_fast_move_to_destination(fr_mm_s);
|
||||
#else
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
#endif
|
||||
if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
|
||||
SERIAL_ECHOLNPGM(STR_ERR_MESH_XY);
|
||||
return;
|
||||
}
|
||||
|
||||
// Move to current_position, as modified by I, J, P parameters
|
||||
destination = current_position;
|
||||
|
||||
if (hasI) destination.x = bedlevel.get_mesh_x(ix);
|
||||
if (hasJ) destination.y = bedlevel.get_mesh_y(iy);
|
||||
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
if (parser.seen_test('P')) {
|
||||
if (hasI) destination.x -= probe.offset_xy.x;
|
||||
if (hasJ) destination.y -= probe.offset_xy.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
const feedRate_t fval = parser.linearval('F'),
|
||||
fr_mm_s = MMM_TO_MMS(fval > 0 ? fval : 0.0f);
|
||||
|
||||
// SCARA kinematic has "safe" XY raw moves
|
||||
#if IS_SCARA
|
||||
prepare_internal_fast_move_to_destination(fr_mm_s);
|
||||
#else
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_MESH
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
#include "../../../core/debug_out.h"
|
||||
|
||||
#if DISABLED(PROBE_MANUALLY) && FT_MOTION_DISABLE_FOR_PROBING
|
||||
#include "../../../module/ft_motion.h"
|
||||
#endif
|
||||
|
||||
#if ABL_USES_GRID
|
||||
#if ENABLED(PROBE_Y_FIRST)
|
||||
#define PR_OUTER_VAR abl.meshCount.x
|
||||
@@ -280,6 +284,10 @@ G29_TYPE GcodeSuite::G29() {
|
||||
// Set and report "probing" state to host
|
||||
TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE, false));
|
||||
|
||||
#if DISABLED(PROBE_MANUALLY) && FT_MOTION_DISABLE_FOR_PROBING
|
||||
FTMotionDisableInScope FT_Disabler; // Disable Fixed-Time Motion for probing
|
||||
#endif
|
||||
|
||||
/**
|
||||
* On the initial G29 fetch command parameters.
|
||||
*/
|
||||
@@ -287,6 +295,11 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
probe.use_probing_tool();
|
||||
|
||||
#ifdef EVENT_GCODE_BEFORE_G29
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Before G29 G-code: ", EVENT_GCODE_BEFORE_G29);
|
||||
gcode.process_subcommands_now(F(EVENT_GCODE_BEFORE_G29));
|
||||
#endif
|
||||
|
||||
#if ANY(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
|
||||
abl.abl_probe_index = -1;
|
||||
#endif
|
||||
@@ -392,7 +405,12 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
#if ABL_USES_GRID
|
||||
|
||||
constexpr feedRate_t min_probe_feedrate_mm_s = XY_PROBE_FEEDRATE_MIN;
|
||||
xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_FEEDRATE));
|
||||
if (xy_probe_feedrate_mm_s < min_probe_feedrate_mm_s) {
|
||||
xy_probe_feedrate_mm_s = min_probe_feedrate_mm_s;
|
||||
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Feedrate (S) too low. (Using ", min_probe_feedrate_mm_s, ")"));
|
||||
}
|
||||
|
||||
const float x_min = probe.min_x(), x_max = probe.max_x(),
|
||||
y_min = probe.min_y(), y_max = probe.max_y();
|
||||
@@ -682,7 +700,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
inInc = -1; // Zag left
|
||||
}
|
||||
|
||||
zig ^= true; // zag
|
||||
FLIP(zig); // zag
|
||||
|
||||
// An index to print current state
|
||||
grid_count_t pt_index = (PR_OUTER_VAR) * (PR_INNER_SIZE) + 1;
|
||||
@@ -1002,7 +1020,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
TERN_(HAS_BED_PROBE, probe.move_z_after_probing());
|
||||
|
||||
#ifdef EVENT_GCODE_AFTER_G29
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", EVENT_GCODE_AFTER_G29);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("After G29 G-code: ", EVENT_GCODE_AFTER_G29);
|
||||
planner.synchronize();
|
||||
process_subcommands_now(F(EVENT_GCODE_AFTER_G29));
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
#include "../../../core/debug_out.h"
|
||||
|
||||
#if FT_MOTION_DISABLE_FOR_PROBING
|
||||
#include "../../module/ft_motion.h"
|
||||
#endif
|
||||
|
||||
// Save 130 bytes with non-duplication of PSTR
|
||||
inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM(" not entered."); }
|
||||
|
||||
@@ -63,6 +67,10 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM("
|
||||
*/
|
||||
void GcodeSuite::G29() {
|
||||
|
||||
#if FT_MOTION_DISABLE_FOR_PROBING
|
||||
FTMotionDisableInScope FT_Disabler; // Disable Fixed-Time Motion for probing
|
||||
#endif
|
||||
|
||||
DEBUG_SECTION(log_G29, "G29", true);
|
||||
|
||||
// G29 Q is also available if debugging
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user