Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9dda85ddd | |||
| beea1f1d14 | |||
| a9072b00e8 | |||
| a530446b62 |
@@ -1,21 +0,0 @@
|
|||||||
# Build artifacts
|
|
||||||
buildroot/
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
*.dll
|
|
||||||
*.exe
|
|
||||||
|
|
||||||
# Web assets
|
|
||||||
*.min.js
|
|
||||||
*.min.css
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# IDE files
|
|
||||||
.vscode/
|
|
||||||
.idea/
|
|
||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
autolabel:
|
autolabel:
|
||||||
name: Auto Label
|
name: Auto Label
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Auto Label for [BUG]
|
- name: Auto Label for [BUG]
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
name: Bump Distribution Date
|
name: Bump Distribution Date
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
name: PR Bad Target
|
name: PR Bad Target
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: superbrothers/close-pull-request@v3
|
- uses: superbrothers/close-pull-request@v3
|
||||||
|
|||||||
@@ -34,16 +34,13 @@ jobs:
|
|||||||
name: Build Test
|
name: Build Test
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
test-platform:
|
test-platform:
|
||||||
|
|
||||||
# RP2040
|
|
||||||
- SKR_Pico
|
|
||||||
|
|
||||||
# Native
|
# Native
|
||||||
- linux_native
|
- linux_native
|
||||||
- simulator_linux_release
|
- simulator_linux_release
|
||||||
@@ -113,7 +110,7 @@ jobs:
|
|||||||
- BTT_GTR_V1_0
|
- BTT_GTR_V1_0
|
||||||
- BTT_SKR_PRO
|
- BTT_SKR_PRO
|
||||||
- FLYF407ZG
|
- FLYF407ZG
|
||||||
- STM32F446VE_fysetc
|
- FYSETC_S6
|
||||||
- LERDGEK
|
- LERDGEK
|
||||||
- LERDGEX
|
- LERDGEX
|
||||||
- mks_robin_pro2
|
- mks_robin_pro2
|
||||||
@@ -188,7 +185,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Simulator dependencies
|
- name: Install Simulator dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install build-essential
|
sudo apt-get install build-essential
|
||||||
sudo apt-get install libsdl2-dev
|
sudo apt-get install libsdl2-dev
|
||||||
sudo apt-get install libsdl2-net-dev
|
sudo apt-get install libsdl2-net-dev
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
# pulls them into additional branches.
|
# pulls them into additional branches.
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the PR
|
- name: Check out the PR
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
name: Validate boards.h
|
name: Validate boards.h
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the PR
|
- name: Check out the PR
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
name: Validate Pins Files
|
name: Validate Pins Files
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the PR
|
- name: Check out the PR
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
remove_label:
|
remove_label:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
name: Close Stale Issues
|
name: Close Stale Issues
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v9
|
- uses: actions/stale@v9
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
name: Lock Closed Issues
|
name: Lock Closed Issues
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: dessant/lock-threads@v5
|
- uses: dessant/lock-threads@v5
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
name: Unlock Reopened
|
name: Unlock Reopened
|
||||||
if: github.repository == 'MarlinFirmware/Marlin'
|
if: github.repository == 'MarlinFirmware/Marlin'
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: OSDKDev/unlock-issues@v1.1
|
- uses: OSDKDev/unlock-issues@v1.1
|
||||||
|
|||||||
@@ -169,6 +169,3 @@ __pycache__
|
|||||||
tags
|
tags
|
||||||
*.logs
|
*.logs
|
||||||
*.bak
|
*.bak
|
||||||
.aider*
|
|
||||||
!.aiderignore
|
|
||||||
.env
|
|
||||||
|
|||||||
+59
-84
@@ -71,8 +71,6 @@
|
|||||||
#define MOTHERBOARD BOARD_RAMPS_14_EFB
|
#define MOTHERBOARD BOARD_RAMPS_14_EFB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// @section serial
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the serial port on the board to use for communication with the host.
|
* Select the serial port on the board to use for communication with the host.
|
||||||
* This allows the connection of wireless adapters (for instance) to non-default port pins.
|
* This allows the connection of wireless adapters (for instance) to non-default port pins.
|
||||||
@@ -129,7 +127,6 @@
|
|||||||
|
|
||||||
// Name displayed in the LCD "Ready" message and Info menu
|
// Name displayed in the LCD "Ready" message and Info menu
|
||||||
//#define CUSTOM_MACHINE_NAME "3D Printer"
|
//#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.
|
// 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
|
// Choose your own or use a service like https://www.uuidgenerator.net/version4
|
||||||
@@ -587,7 +584,7 @@
|
|||||||
#define DUMMY_THERMISTOR_998_VALUE 25
|
#define DUMMY_THERMISTOR_998_VALUE 25
|
||||||
#define DUMMY_THERMISTOR_999_VALUE 100
|
#define DUMMY_THERMISTOR_999_VALUE 100
|
||||||
|
|
||||||
// Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 / 2 / BED
|
// Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1
|
||||||
#if TEMP_SENSOR_IS_MAX_TC(0)
|
#if TEMP_SENSOR_IS_MAX_TC(0)
|
||||||
#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000)
|
#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
|
#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000
|
||||||
@@ -600,10 +597,6 @@
|
|||||||
#define MAX31865_SENSOR_OHMS_2 100
|
#define MAX31865_SENSOR_OHMS_2 100
|
||||||
#define MAX31865_CALIBRATION_OHMS_2 430
|
#define MAX31865_CALIBRATION_OHMS_2 430
|
||||||
#endif
|
#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
|
#if HAS_E_TEMP_SENSOR
|
||||||
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
|
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
|
||||||
@@ -696,7 +689,6 @@
|
|||||||
#define PID_K1 0.95 // Smoothing factor within any PID loop
|
#define PID_K1 0.95 // Smoothing factor within any PID loop
|
||||||
|
|
||||||
#if ENABLED(PIDTEMP)
|
#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_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation.
|
||||||
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
|
//#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders)
|
||||||
// Set/get with G-code: M301 E[extruder number, 0-2]
|
// Set/get with G-code: M301 E[extruder number, 0-2]
|
||||||
@@ -949,7 +941,7 @@
|
|||||||
//============================= Mechanical Settings =========================
|
//============================= Mechanical Settings =========================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
// @section kinematics
|
// @section machine
|
||||||
|
|
||||||
// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics,
|
// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics,
|
||||||
// either in the usual order or reversed
|
// either in the usual order or reversed
|
||||||
@@ -973,15 +965,6 @@
|
|||||||
// Enable for a belt style printer with endless "Z" motion
|
// Enable for a belt style printer with endless "Z" motion
|
||||||
//#define BELTPRINTER
|
//#define BELTPRINTER
|
||||||
|
|
||||||
// Articulated robot (arm). Joints are directly mapped to axes with no kinematics.
|
|
||||||
//#define ARTICULATED_ROBOT_ARM
|
|
||||||
|
|
||||||
// For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire
|
|
||||||
// ends are controlled by parallel axes (Y, J). Joints are directly mapped to axes (no kinematics).
|
|
||||||
//#define FOAMCUTTER_XYUV
|
|
||||||
|
|
||||||
// @section polargraph
|
|
||||||
|
|
||||||
// Enable for Polargraph Kinematics
|
// Enable for Polargraph Kinematics
|
||||||
//#define POLARGRAPH
|
//#define POLARGRAPH
|
||||||
#if ENABLED(POLARGRAPH)
|
#if ENABLED(POLARGRAPH)
|
||||||
@@ -1168,6 +1151,15 @@
|
|||||||
#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
|
#define FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// @section machine
|
||||||
|
|
||||||
|
// Articulated robot (arm). Joints are directly mapped to axes with no kinematics.
|
||||||
|
//#define ARTICULATED_ROBOT_ARM
|
||||||
|
|
||||||
|
// For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire
|
||||||
|
// ends are controlled by parallel axes (Y, J). Joints are directly mapped to axes (no kinematics).
|
||||||
|
//#define FOAMCUTTER_XYUV
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//============================== Endstop Settings ===========================
|
//============================== Endstop Settings ===========================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@@ -1513,6 +1505,7 @@
|
|||||||
* For information about this sensor https://github.com/bigtreetech/MicroProbe
|
* For information about this sensor https://github.com/bigtreetech/MicroProbe
|
||||||
*
|
*
|
||||||
* Also requires PROBE_ENABLE_DISABLE
|
* Also requires PROBE_ENABLE_DISABLE
|
||||||
|
* With FT_MOTION requires ENDSTOP_INTERRUPTS_FEATURE
|
||||||
*/
|
*/
|
||||||
//#define BIQU_MICROPROBE_V1 // Triggers HIGH
|
//#define BIQU_MICROPROBE_V1 // Triggers HIGH
|
||||||
//#define BIQU_MICROPROBE_V2 // Triggers LOW
|
//#define BIQU_MICROPROBE_V2 // Triggers LOW
|
||||||
@@ -1651,15 +1644,15 @@
|
|||||||
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
|
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
|
||||||
#define PROBING_MARGIN 10
|
#define PROBING_MARGIN 10
|
||||||
|
|
||||||
// X and Y axis travel speed between probes.
|
// X and Y axis travel speed (mm/min) between probes.
|
||||||
// Leave undefined to use the average of the current XY homing feedrate.
|
// Leave undefined to use the average of the current XY homing feedrate.
|
||||||
#define XY_PROBE_FEEDRATE (133*60) // (mm/min)
|
#define XY_PROBE_FEEDRATE (133*60)
|
||||||
|
|
||||||
// Feedrate for the first approach when double-probing (MULTIPLE_PROBING == 2)
|
// Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2)
|
||||||
#define Z_PROBE_FEEDRATE_FAST (4*60) // (mm/min)
|
#define Z_PROBE_FEEDRATE_FAST (4*60)
|
||||||
|
|
||||||
// Feedrate for the "accurate" probe of each point
|
// Feedrate (mm/min) for the "accurate" probe of each point
|
||||||
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2) // (mm/min)
|
#define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Probe Activation Switch
|
* Probe Activation Switch
|
||||||
@@ -1776,17 +1769,17 @@
|
|||||||
// @section stepper drivers
|
// @section stepper drivers
|
||||||
|
|
||||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||||
// :['LOW', 'HIGH']
|
// :{ 0:'Low', 1:'High' }
|
||||||
#define X_ENABLE_ON LOW
|
#define X_ENABLE_ON 0
|
||||||
#define Y_ENABLE_ON LOW
|
#define Y_ENABLE_ON 0
|
||||||
#define Z_ENABLE_ON LOW
|
#define Z_ENABLE_ON 0
|
||||||
#define E_ENABLE_ON LOW // For all extruders
|
#define E_ENABLE_ON 0 // For all extruders
|
||||||
//#define I_ENABLE_ON LOW
|
//#define I_ENABLE_ON 0
|
||||||
//#define J_ENABLE_ON LOW
|
//#define J_ENABLE_ON 0
|
||||||
//#define K_ENABLE_ON LOW
|
//#define K_ENABLE_ON 0
|
||||||
//#define U_ENABLE_ON LOW
|
//#define U_ENABLE_ON 0
|
||||||
//#define V_ENABLE_ON LOW
|
//#define V_ENABLE_ON 0
|
||||||
//#define W_ENABLE_ON LOW
|
//#define W_ENABLE_ON 0
|
||||||
|
|
||||||
// Disable axis steppers immediately when they're not being stepped.
|
// Disable axis steppers immediately when they're not being stepped.
|
||||||
// WARNING: When motors turn off there is a chance of losing position accuracy!
|
// WARNING: When motors turn off there is a chance of losing position accuracy!
|
||||||
@@ -2061,9 +2054,9 @@
|
|||||||
//#define FIL_MOTION8_PULLUP
|
//#define FIL_MOTION8_PULLUP
|
||||||
//#define FIL_MOTION8_PULLDOWN
|
//#define FIL_MOTION8_PULLDOWN
|
||||||
#endif
|
#endif
|
||||||
#endif // FILAMENT_MOTION_SENSOR
|
#endif
|
||||||
#endif // FILAMENT_RUNOUT_DISTANCE_MM
|
#endif
|
||||||
#endif // FILAMENT_RUNOUT_SENSOR
|
#endif
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//=============================== Bed Leveling ==============================
|
//=============================== Bed Leveling ==============================
|
||||||
@@ -2109,12 +2102,6 @@
|
|||||||
//#define AUTO_BED_LEVELING_UBL
|
//#define AUTO_BED_LEVELING_UBL
|
||||||
//#define MESH_BED_LEVELING
|
//#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.
|
* Commands to execute at the end of G29 probing.
|
||||||
* Useful to retract or move the Z probe out of the way.
|
* Useful to retract or move the Z probe out of the way.
|
||||||
@@ -2899,15 +2886,13 @@
|
|||||||
//
|
//
|
||||||
//#define MAKEBOARD_MINI_2_LINE_DISPLAY_1602
|
//#define MAKEBOARD_MINI_2_LINE_DISPLAY_1602
|
||||||
|
|
||||||
/**
|
//
|
||||||
* ANET and Tronxy 20x4 Controller
|
// ANET and Tronxy 20x4 Controller
|
||||||
* LCD2004 display with 5 analog buttons.
|
//
|
||||||
*
|
//#define ZONESTAR_LCD // Requires ADC_KEYPAD_PIN to be assigned to an analog pin.
|
||||||
* NOTE: Requires ADC_KEYPAD_PIN to be assigned to an analog pin.
|
// This LCD is known to be susceptible to electrical interference
|
||||||
* This LCD is known to be susceptible to electrical interference which
|
// which scrambles the display. Pressing any button clears it up.
|
||||||
* scrambles the display. Press any button to clear it up.
|
// This is a LCD2004 display with 5 analog buttons.
|
||||||
*/
|
|
||||||
//#define ZONESTAR_LCD
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generic 16x2, 16x4, 20x2, or 20x4 character-based LCD.
|
// Generic 16x2, 16x4, 20x2, or 20x4 character-based LCD.
|
||||||
@@ -3184,14 +3169,14 @@
|
|||||||
//
|
//
|
||||||
// Tiny, but very sharp OLED display
|
// Tiny, but very sharp OLED display
|
||||||
//
|
//
|
||||||
//#define MKS_12864OLED // Uses the SH1106 controller
|
//#define MKS_12864OLED // Uses the SH1106 controller (default)
|
||||||
//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
|
//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller
|
||||||
|
|
||||||
//
|
//
|
||||||
// Zonestar OLED 128×64 Full Graphics Controller
|
// Zonestar OLED 128×64 Full Graphics Controller
|
||||||
//
|
//
|
||||||
//#define ZONESTAR_12864LCD // Graphical (DOGM) with ST7920 controller
|
//#define ZONESTAR_12864LCD // Graphical (DOGM) with ST7920 controller
|
||||||
//#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller
|
//#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller (default)
|
||||||
//#define ZONESTAR_12864OLED_SSD1306 // 0.96" OLED with SSD1306 controller
|
//#define ZONESTAR_12864OLED_SSD1306 // 0.96" OLED with SSD1306 controller
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3440,7 +3425,7 @@
|
|||||||
|
|
||||||
#if ENABLED(TFT_COLOR_UI)
|
#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.
|
* 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.
|
* UNIFONT - Lightweight font, no anti-aliasing. Supports Latin Extended and non-Latin characters.
|
||||||
@@ -3449,7 +3434,7 @@
|
|||||||
#define TFT_FONT NOTOSANS
|
#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
|
* BLUE_MARLIN - Default theme with 'midnight blue' background
|
||||||
* BLACK_MARLIN - Theme with 'black' background
|
* BLACK_MARLIN - Theme with 'black' background
|
||||||
@@ -3473,8 +3458,6 @@
|
|||||||
* TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y,
|
* TFT_ROTATE_180, TFT_ROTATE_180_MIRROR_X, TFT_ROTATE_180_MIRROR_Y,
|
||||||
* TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
|
* TFT_ROTATE_270, TFT_ROTATE_270_MIRROR_X, TFT_ROTATE_270_MIRROR_Y,
|
||||||
* TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
|
* TFT_MIRROR_X, TFT_MIRROR_Y, TFT_NO_ROTATION
|
||||||
*
|
|
||||||
* :{ 'TFT_NO_ROTATION':'None', 'TFT_ROTATE_90':'90°', 'TFT_ROTATE_90_MIRROR_X':'90° (Mirror X)', 'TFT_ROTATE_90_MIRROR_Y':'90° (Mirror Y)', 'TFT_ROTATE_180':'180°', 'TFT_ROTATE_180_MIRROR_X':'180° (Mirror X)', 'TFT_ROTATE_180_MIRROR_Y':'180° (Mirror Y)', 'TFT_ROTATE_270':'270°', 'TFT_ROTATE_270_MIRROR_X':'270° (Mirror X)', 'TFT_ROTATE_270_MIRROR_Y':'270° (Mirror Y)', 'TFT_MIRROR_X':'Mirror X', 'TFT_MIRROR_Y':'Mirror Y' }
|
|
||||||
*/
|
*/
|
||||||
//#define TFT_ROTATION TFT_NO_ROTATION
|
//#define TFT_ROTATION TFT_NO_ROTATION
|
||||||
|
|
||||||
@@ -3525,9 +3508,7 @@
|
|||||||
// https://reprapworld.com/products/electronics/ramps/keypad_v1_0_fully_assembled/
|
// https://reprapworld.com/products/electronics/ramps/keypad_v1_0_fully_assembled/
|
||||||
//
|
//
|
||||||
//#define REPRAPWORLD_KEYPAD
|
//#define REPRAPWORLD_KEYPAD
|
||||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
|
||||||
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // (mm) Distance to move per key-press
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// EasyThreeD ET-4000+ with button input and status LED
|
// EasyThreeD ET-4000+ with button input and status LED
|
||||||
@@ -3544,26 +3525,22 @@
|
|||||||
// :[1,2,3,4,5,6,7,8]
|
// :[1,2,3,4,5,6,7,8]
|
||||||
//#define NUM_M106_FANS 1
|
//#define NUM_M106_FANS 1
|
||||||
|
|
||||||
/**
|
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
|
||||||
* 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
|
||||||
* 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.
|
||||||
* is too low, you should also increment SOFT_PWM_SCALE.
|
|
||||||
*/
|
|
||||||
//#define FAN_SOFT_PWM
|
//#define FAN_SOFT_PWM
|
||||||
|
|
||||||
/**
|
// Incrementing this by 1 will double the software PWM frequency,
|
||||||
* Incrementing this by 1 will double the software PWM frequency, affecting heaters, and
|
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
|
||||||
* the fan if FAN_SOFT_PWM is enabled. However, control resolution will be halved for each
|
// However, control resolution will be halved for each increment;
|
||||||
* increment; at zero value, there are 128 effective control positions.
|
// at zero value, there are 128 effective control positions.
|
||||||
* :[0,1,2,3,4,5,6,7]
|
// :[0,1,2,3,4,5,6,7]
|
||||||
*/
|
|
||||||
#define SOFT_PWM_SCALE 0
|
#define SOFT_PWM_SCALE 0
|
||||||
|
|
||||||
/**
|
// If SOFT_PWM_SCALE is set to a value higher than 0, dithering can
|
||||||
* If SOFT_PWM_SCALE is set to a value higher than 0, dithering can be used to mitigate the
|
// be used to mitigate the associated resolution loss. If enabled,
|
||||||
* associated resolution loss. If enabled, some of the PWM cycles are stretched so on average
|
// some of the PWM cycles are stretched so on average the desired
|
||||||
* the desired duty cycle is attained.
|
// duty cycle is attained.
|
||||||
*/
|
|
||||||
//#define SOFT_PWM_DITHER
|
//#define SOFT_PWM_DITHER
|
||||||
|
|
||||||
// @section extras
|
// @section extras
|
||||||
@@ -3573,11 +3550,9 @@
|
|||||||
|
|
||||||
// @section lights
|
// @section lights
|
||||||
|
|
||||||
/**
|
// Temperature status LEDs that display the hotend and bed temperature.
|
||||||
* Temperature status LEDs that display the hotend and bed temperature.
|
// If all hotends, bed temperature, and target temperature are under 54C
|
||||||
* 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)
|
||||||
* the BLUE led is on. Otherwise the RED led is on. (1C hysteresis)
|
|
||||||
*/
|
|
||||||
//#define TEMP_STAT_LEDS
|
//#define TEMP_STAT_LEDS
|
||||||
|
|
||||||
// Support for BlinkM/CyzRgb
|
// Support for BlinkM/CyzRgb
|
||||||
|
|||||||
+52
-63
@@ -174,10 +174,9 @@
|
|||||||
* Thermocouple Options — for MAX6675 (-2), MAX31855 (-3), and MAX31865 (-5).
|
* 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 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_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_1 2
|
||||||
//#define MAX31865_SENSOR_WIRES_2 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_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.
|
//#define MAX31865_USE_READ_ERROR_DETECTION // Treat value spikes (20°C delta in under 1s) as read errors.
|
||||||
@@ -189,7 +188,6 @@
|
|||||||
//#define MAX31865_WIRE_OHMS_0 0.95f // For 2-wire, set the wire resistances for more accurate readings.
|
//#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_1 0.0f
|
||||||
//#define MAX31865_WIRE_OHMS_2 0.0f
|
//#define MAX31865_WIRE_OHMS_2 0.0f
|
||||||
//#define MAX31865_WIRE_OHMS_BED 0.0f
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hephestos 2 24V heated bed upgrade kit.
|
* Hephestos 2 24V heated bed upgrade kit.
|
||||||
@@ -213,19 +211,18 @@
|
|||||||
//
|
//
|
||||||
// Heated Chamber options
|
// 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
|
#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_PIN P2_04 // Required heater on/off pin (example: SKR 1.4 Turbo HE1 plug)
|
||||||
//#define HEATER_CHAMBER_INVERTING false
|
//#define HEATER_CHAMBER_INVERTING false
|
||||||
//#define FAN1_PIN -1 // Remove the fan signal on pin P2_04 (example: SKR 1.4 Turbo HE1 plug)
|
//#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
|
//#define CHAMBER_FAN // Enable a fan on the chamber
|
||||||
#if ENABLED(CHAMBER_FAN)
|
#if ENABLED(CHAMBER_FAN)
|
||||||
//#define CHAMBER_FAN_INDEX 2 // Index of a fan to repurpose as the chamber fan. (Default: first unused fan)
|
//#define CHAMBER_FAN_INDEX 2 // Index of a fan to repurpose as the chamber fan. (Default: first unused fan)
|
||||||
@@ -1022,7 +1019,7 @@
|
|||||||
|
|
||||||
#endif // BLTOUCH
|
#endif // BLTOUCH
|
||||||
|
|
||||||
// @section calibrate
|
// @section calibration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Z Steppers Auto-Alignment
|
* Z Steppers Auto-Alignment
|
||||||
@@ -1263,8 +1260,8 @@
|
|||||||
#define DISABLE_IDLE_E // Shut down all idle extruders
|
#define DISABLE_IDLE_E // Shut down all idle extruders
|
||||||
|
|
||||||
// Default Minimum Feedrates for printing and travel moves
|
// Default Minimum Feedrates for printing and travel moves
|
||||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S.
|
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum feedrate. Set with M205 S.
|
||||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T.
|
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum travel feedrate. Set with M205 T.
|
||||||
|
|
||||||
// Minimum time that a segment needs to take as the buffer gets emptied
|
// Minimum time that a segment needs to take as the buffer gets emptied
|
||||||
#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B.
|
#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B.
|
||||||
@@ -1419,24 +1416,24 @@
|
|||||||
#define MICROSTEP_MODES { 16, 16, 16, 16, 16, 16 } // [1,2,4,8,16]
|
#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:
|
* The power on motor currents are set by:
|
||||||
* PWM_MOTOR_CURRENT - used by MINIRAMBO & ULTIMAIN_2
|
* PWM_MOTOR_CURRENT - used by MINIRAMBO & ULTIMAIN_2
|
||||||
* known compatible chips: A4982
|
* known compatible chips: A4982
|
||||||
* DIGIPOT_MOTOR_CURRENT - used by BQ_ZUM_MEGA_3D, RAMBO & SCOOVO_X9H
|
* DIGIPOT_MOTOR_CURRENT - used by BQ_ZUM_MEGA_3D, RAMBO & SCOOVO_X9H
|
||||||
* known compatible chips: AD5206
|
* known compatible chips: AD5206
|
||||||
* DAC_MOTOR_CURRENT_DEFAULT - used by PRINTRBOARD_REVF & RIGIDBOARD_V2
|
* DAC_MOTOR_CURRENT_DEFAULT - used by PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||||
* known compatible chips: MCP4728
|
* known compatible chips: MCP4728
|
||||||
* DIGIPOT_I2C_MOTOR_CURRENTS - used by 5DPRINT, AZTEEG_X3_PRO, AZTEEG_X5_MINI_WIFI, MIGHTYBOARD_REVE
|
* DIGIPOT_I2C_MOTOR_CURRENTS - used by 5DPRINT, AZTEEG_X3_PRO, AZTEEG_X5_MINI_WIFI, MIGHTYBOARD_REVE
|
||||||
* known compatible chips: MCP4451, MCP4018
|
* known compatible chips: MCP4451, MCP4018
|
||||||
*
|
*
|
||||||
* Motor currents can also be set by M907 - M910 and by the LCD.
|
* Motor currents can also be set by M907 - M910 and by the LCD.
|
||||||
* M907 - applies to all.
|
* M907 - applies to all.
|
||||||
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
|
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
|
||||||
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
|
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
|
||||||
*/
|
*/
|
||||||
//#define PWM_MOTOR_CURRENT { 1300, 1300, 1250 } // Values in milliamps
|
//#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)
|
//#define DIGIPOT_MOTOR_CURRENT { 135,135,135,135,135 } // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
|
||||||
@@ -1551,7 +1548,6 @@
|
|||||||
//#define LCD_INFO_MENU
|
//#define LCD_INFO_MENU
|
||||||
#if ENABLED(LCD_INFO_MENU)
|
#if ENABLED(LCD_INFO_MENU)
|
||||||
//#define LCD_PRINTER_INFO_IS_BOOTSCREEN // Show bootscreen(s) instead of Printer Info pages
|
//#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
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1619,10 +1615,6 @@
|
|||||||
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
|
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
|
||||||
#define SOUND_ON_DEFAULT // Buzzer/speaker default enabled state
|
#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
|
#if HAS_WIRED_LCD
|
||||||
//#define DOUBLE_LCD_FRAMERATE // Not recommended for slow boards.
|
//#define DOUBLE_LCD_FRAMERATE // Not recommended for slow boards.
|
||||||
#endif
|
#endif
|
||||||
@@ -1874,7 +1866,7 @@
|
|||||||
*
|
*
|
||||||
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
|
* SCLK, MOSI, MISO --> SCLK, MOSI, MISO
|
||||||
* INT --> SD_DETECT_PIN [1]
|
* INT --> SD_DETECT_PIN [1]
|
||||||
* SS --> SD_SS_PIN
|
* SS --> SDSS
|
||||||
*
|
*
|
||||||
* [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
|
* [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
|
||||||
*/
|
*/
|
||||||
@@ -1901,7 +1893,7 @@
|
|||||||
//#define USE_OTG_USB_HOST
|
//#define USE_OTG_USB_HOST
|
||||||
|
|
||||||
#if DISABLED(USE_OTG_USB_HOST)
|
#if DISABLED(USE_OTG_USB_HOST)
|
||||||
#define USB_CS_PIN SD_SS_PIN
|
#define USB_CS_PIN SDSS
|
||||||
#define USB_INTR_PIN SD_DETECT_PIN
|
#define USB_INTR_PIN SD_DETECT_PIN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -2012,7 +2004,7 @@
|
|||||||
#if IS_U8GLIB_ST7920
|
#if IS_U8GLIB_ST7920
|
||||||
// Enable this option and reduce the value to optimize screen updates.
|
// 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.
|
// The normal delay is 10µs. Use the lowest value that still gives a reliable display.
|
||||||
//#define DOGM_SPI_DELAY_US 5 // (µs) Delay after each SPI transfer
|
//#define DOGM_SPI_DELAY_US 5
|
||||||
|
|
||||||
//#define LIGHTWEIGHT_UI
|
//#define LIGHTWEIGHT_UI
|
||||||
#if ENABLED(LIGHTWEIGHT_UI)
|
#if ENABLED(LIGHTWEIGHT_UI)
|
||||||
@@ -2042,17 +2034,17 @@
|
|||||||
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
|
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
|
||||||
//#define STATUS_HEAT_POWER // Show heater output power as a vertical bar
|
//#define STATUS_HEAT_POWER // Show heater output power as a vertical bar
|
||||||
|
|
||||||
#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
|
// Frivolous Game Options
|
||||||
//#define MARLIN_BRICKOUT
|
//#define MARLIN_BRICKOUT
|
||||||
//#define MARLIN_INVADERS
|
//#define MARLIN_INVADERS
|
||||||
//#define MARLIN_SNAKE
|
//#define MARLIN_SNAKE
|
||||||
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
|
//#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2231,7 +2223,7 @@
|
|||||||
|
|
||||||
// Developer menu (accessed by touching "About Printer" copyright text)
|
// Developer menu (accessed by touching "About Printer" copyright text)
|
||||||
//#define TOUCH_UI_DEVELOPER_MENU
|
//#define TOUCH_UI_DEVELOPER_MENU
|
||||||
#endif // TOUCH_UI_FTDI_EVE
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Classic UI Options
|
// Classic UI Options
|
||||||
@@ -2265,7 +2257,7 @@
|
|||||||
// ADC Button Debounce
|
// ADC Button Debounce
|
||||||
//
|
//
|
||||||
#if HAS_ADC_BUTTONS
|
#if HAS_ADC_BUTTONS
|
||||||
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (count) Increase if buttons bounce or repeat too fast
|
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // Increase if buttons bounce or repeat too fast
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// @section safety
|
// @section safety
|
||||||
@@ -2306,7 +2298,7 @@
|
|||||||
|
|
||||||
//#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
|
//#define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping.
|
||||||
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
|
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
|
||||||
#define DOUBLECLICK_MAX_INTERVAL 1250 // (ms) Maximum interval between clicks.
|
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
|
||||||
// Note: Extra time may be added to mitigate controller latency.
|
// 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.
|
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on double-click when printer is idle.
|
||||||
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
||||||
@@ -2638,23 +2630,19 @@
|
|||||||
#define MAX_CMD_SIZE 96
|
#define MAX_CMD_SIZE 96
|
||||||
#define BUFSIZE 4
|
#define BUFSIZE 4
|
||||||
|
|
||||||
/**
|
// Transmission to Host Buffer Size
|
||||||
* Host Transmit Buffer Size
|
// To save 386 bytes of flash (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
|
||||||
* - Costs 386 bytes of flash and TX_BUFFER_SIZE+3 bytes of SRAM (if not 0).
|
// To buffer a simple "ok" you need 4 bytes.
|
||||||
* - 4 bytes required to buffer a simple "ok".
|
// For ADVANCED_OK (M105) you need 32 bytes.
|
||||||
* - 32 bytes for ADVANCED_OK (M105).
|
// For debug-echo: 128 bytes for the optimal speed.
|
||||||
* - 128 bytes for the optimal speed of 'debug-echo:'
|
// Other output doesn't need to be that speedy.
|
||||||
* - Other output doesn't need to be that speedy.
|
// :[0, 2, 4, 8, 16, 32, 64, 128, 256]
|
||||||
* :[0, 2, 4, 8, 16, 32, 64, 128, 256]
|
|
||||||
*/
|
|
||||||
#define TX_BUFFER_SIZE 0
|
#define TX_BUFFER_SIZE 0
|
||||||
|
|
||||||
/**
|
// Host Receive Buffer Size
|
||||||
* Host Receive Buffer Size
|
// Without XON/XOFF flow control (see SERIAL_XON_XOFF below) 32 bytes should be enough.
|
||||||
* 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.
|
||||||
* 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]
|
||||||
* :[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
|
|
||||||
*/
|
|
||||||
//#define RX_BUFFER_SIZE 1024
|
//#define RX_BUFFER_SIZE 1024
|
||||||
|
|
||||||
#if RX_BUFFER_SIZE >= 1024
|
#if RX_BUFFER_SIZE >= 1024
|
||||||
@@ -3921,7 +3909,7 @@
|
|||||||
/**
|
/**
|
||||||
* Extra options for the M114 "Current Position" report
|
* Extra options for the M114 "Current Position" report
|
||||||
*/
|
*/
|
||||||
//#define M114_DETAIL // Use 'M114 D' for details to check planner calculations
|
//#define M114_DETAIL // Use 'M114` for details to check planner calculations
|
||||||
//#define M114_REALTIME // Real current position based on forward kinematics
|
//#define M114_REALTIME // Real current position based on forward kinematics
|
||||||
//#define M114_LEGACY // M114 used to synchronize on every call. Enable if needed.
|
//#define M114_LEGACY // M114 used to synchronize on every call. Enable if needed.
|
||||||
|
|
||||||
@@ -3968,6 +3956,7 @@
|
|||||||
* Spend 28 bytes of SRAM to optimize the G-code parser
|
* Spend 28 bytes of SRAM to optimize the G-code parser
|
||||||
*/
|
*/
|
||||||
#define FASTER_GCODE_PARSER
|
#define FASTER_GCODE_PARSER
|
||||||
|
|
||||||
#if ENABLED(FASTER_GCODE_PARSER)
|
#if ENABLED(FASTER_GCODE_PARSER)
|
||||||
//#define GCODE_QUOTED_STRINGS // Support for quoted string parameters
|
//#define GCODE_QUOTED_STRINGS // Support for quoted string parameters
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -1026,7 +1026,7 @@ extcoff: $(TARGET).elf
|
|||||||
$(NM) -n $< > $@
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
# Link: create ELF output file from library.
|
# Link: create ELF output file from library.
|
||||||
LDFLAGS+= -Wl,-V
|
|
||||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
|
||||||
$(Pecho) " CXX $@"
|
$(Pecho) " CXX $@"
|
||||||
$P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
|
$P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
|
||||||
|
|||||||
+3
-10
@@ -41,14 +41,7 @@
|
|||||||
* here we define this default string as the date where the latest release
|
* here we define this default string as the date where the latest release
|
||||||
* version was tagged.
|
* version was tagged.
|
||||||
*/
|
*/
|
||||||
//#define STRING_DISTRIBUTION_DATE "2025-03-18"
|
//#define STRING_DISTRIBUTION_DATE "2024-10-17"
|
||||||
|
|
||||||
/**
|
|
||||||
* The protocol for communication to the host. Protocol indicates communication
|
|
||||||
* standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
|
|
||||||
* (Other behaviors are given by the firmware version and capabilities report.)
|
|
||||||
*/
|
|
||||||
//#define PROTOCOL_VERSION "1.0"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||||
@@ -75,8 +68,8 @@
|
|||||||
//#define WEBSITE_URL "marlinfw.org"
|
//#define WEBSITE_URL "marlinfw.org"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the vendor info the serial USB interface, if changeable.
|
* Set the vendor info the serial USB interface, if changable
|
||||||
* Currently only supported by DUE platform.
|
* Currently only supported by DUE platform
|
||||||
*/
|
*/
|
||||||
//#define USB_DEVICE_VENDOR_ID 0x0000
|
//#define USB_DEVICE_VENDOR_ID 0x0000
|
||||||
//#define USB_DEVICE_PRODUCT_ID 0x0000
|
//#define USB_DEVICE_PRODUCT_ID 0x0000
|
||||||
|
|||||||
+44
-41
@@ -62,11 +62,6 @@ motherboard = BOARD_RAMPS_14_EFB
|
|||||||
serial_port = 0
|
serial_port = 0
|
||||||
baudrate = 250000
|
baudrate = 250000
|
||||||
|
|
||||||
string_config_h_author = "(default from config.ini)"
|
|
||||||
|
|
||||||
capabilities_report = on
|
|
||||||
extended_capabilities_report = on
|
|
||||||
|
|
||||||
use_watchdog = on
|
use_watchdog = on
|
||||||
thermal_protection_hotends = on
|
thermal_protection_hotends = on
|
||||||
thermal_protection_hysteresis = 4
|
thermal_protection_hysteresis = 4
|
||||||
@@ -82,7 +77,9 @@ temp_sensor_0 = 1
|
|||||||
temp_hysteresis = 3
|
temp_hysteresis = 3
|
||||||
heater_0_mintemp = 5
|
heater_0_mintemp = 5
|
||||||
heater_0_maxtemp = 275
|
heater_0_maxtemp = 275
|
||||||
|
preheat_1_temp_hotend = 180
|
||||||
|
|
||||||
|
bang_max = 255
|
||||||
pidtemp = on
|
pidtemp = on
|
||||||
pid_k1 = 0.95
|
pid_k1 = 0.95
|
||||||
pid_max = 255
|
pid_max = 255
|
||||||
@@ -92,14 +89,6 @@ default_kp = 22.20
|
|||||||
default_ki = 1.08
|
default_ki = 1.08
|
||||||
default_kd = 114.00
|
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
|
x_driver_type = A4988
|
||||||
y_driver_type = A4988
|
y_driver_type = A4988
|
||||||
z_driver_type = A4988
|
z_driver_type = A4988
|
||||||
@@ -132,10 +121,10 @@ default_max_acceleration = { 3000, 3000, 100, 10000 }
|
|||||||
homing_feedrate_mm_m = { (50*60), (50*60), (4*60) }
|
homing_feedrate_mm_m = { (50*60), (50*60), (4*60) }
|
||||||
homing_bump_divisor = { 2, 2, 4 }
|
homing_bump_divisor = { 2, 2, 4 }
|
||||||
|
|
||||||
x_enable_on = LOW
|
x_enable_on = 0
|
||||||
y_enable_on = LOW
|
y_enable_on = 0
|
||||||
z_enable_on = LOW
|
z_enable_on = 0
|
||||||
e_enable_on = LOW
|
e_enable_on = 0
|
||||||
|
|
||||||
invert_x_dir = false
|
invert_x_dir = false
|
||||||
invert_y_dir = true
|
invert_y_dir = true
|
||||||
@@ -147,6 +136,11 @@ step_state_x = HIGH
|
|||||||
step_state_y = HIGH
|
step_state_y = HIGH
|
||||||
step_state_z = HIGH
|
step_state_z = HIGH
|
||||||
|
|
||||||
|
disable_x = off
|
||||||
|
disable_y = off
|
||||||
|
disable_z = off
|
||||||
|
disable_e = off
|
||||||
|
|
||||||
proportional_font_ratio = 1.0
|
proportional_font_ratio = 1.0
|
||||||
default_nominal_filament_dia = 1.75
|
default_nominal_filament_dia = 1.75
|
||||||
|
|
||||||
@@ -159,13 +153,18 @@ default_retract_acceleration = 3000
|
|||||||
default_minimumfeedrate = 0.0
|
default_minimumfeedrate = 0.0
|
||||||
default_mintravelfeedrate = 0.0
|
default_mintravelfeedrate = 0.0
|
||||||
|
|
||||||
|
minimum_planner_speed = 0.05
|
||||||
min_steps_per_segment = 6
|
min_steps_per_segment = 6
|
||||||
default_minsegmenttime = 20000
|
default_minsegmenttime = 20000
|
||||||
|
|
||||||
[config:basic]
|
[config:basic]
|
||||||
bed_overshoot = 10
|
bed_overshoot = 10
|
||||||
busy_while_heating = on
|
busy_while_heating = on
|
||||||
|
default_ejerk = 5.0
|
||||||
default_keepalive_interval = 2
|
default_keepalive_interval = 2
|
||||||
|
default_leveling_fade_height = 0.0
|
||||||
|
disable_other_extruders = on
|
||||||
|
display_charset_hd44780 = JAPANESE
|
||||||
eeprom_boot_silent = on
|
eeprom_boot_silent = on
|
||||||
eeprom_chitchat = on
|
eeprom_chitchat = on
|
||||||
endstoppullups = on
|
endstoppullups = on
|
||||||
@@ -174,8 +173,10 @@ extrude_mintemp = 170
|
|||||||
host_keepalive_feature = on
|
host_keepalive_feature = on
|
||||||
hotend_overshoot = 15
|
hotend_overshoot = 15
|
||||||
jd_handle_small_segments = on
|
jd_handle_small_segments = on
|
||||||
|
lcd_info_screen_style = 0
|
||||||
|
lcd_language = en
|
||||||
max_bed_power = 255
|
max_bed_power = 255
|
||||||
|
mesh_inset = 0
|
||||||
min_software_endstops = on
|
min_software_endstops = on
|
||||||
max_software_endstops = on
|
max_software_endstops = on
|
||||||
min_software_endstop_x = on
|
min_software_endstop_x = on
|
||||||
@@ -184,48 +185,50 @@ min_software_endstop_z = on
|
|||||||
max_software_endstop_x = on
|
max_software_endstop_x = on
|
||||||
max_software_endstop_y = on
|
max_software_endstop_y = on
|
||||||
max_software_endstop_z = on
|
max_software_endstop_z = on
|
||||||
|
|
||||||
preheat_1_label = "PLA"
|
|
||||||
preheat_1_temp_hotend = 180
|
|
||||||
preheat_1_temp_bed = 70
|
|
||||||
preheat_1_fan_speed = 0
|
preheat_1_fan_speed = 0
|
||||||
|
preheat_1_label = "PLA"
|
||||||
preheat_2_label = "ABS"
|
preheat_1_temp_bed = 70
|
||||||
preheat_2_temp_hotend = 240
|
|
||||||
preheat_2_temp_bed = 110
|
|
||||||
preheat_2_fan_speed = 0
|
|
||||||
|
|
||||||
prevent_cold_extrusion = on
|
prevent_cold_extrusion = on
|
||||||
prevent_lengthy_extrude = on
|
prevent_lengthy_extrude = on
|
||||||
printjob_timer_autostart = 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_hysteresis = 3
|
||||||
temp_bed_residency_time = 10
|
temp_bed_residency_time = 10
|
||||||
temp_bed_window = 1
|
temp_bed_window = 1
|
||||||
temp_residency_time = 10
|
temp_residency_time = 10
|
||||||
temp_window = 1
|
temp_window = 1
|
||||||
validate_homing_endstops = on
|
validate_homing_endstops = on
|
||||||
|
xy_probe_feedrate = (133*60)
|
||||||
editable_steps_per_unit = on
|
z_clearance_between_probes = 5
|
||||||
|
z_clearance_deploy_probe = 10
|
||||||
|
z_clearance_multi_probe = 5
|
||||||
|
|
||||||
[config:advanced]
|
[config:advanced]
|
||||||
arc_support = on
|
arc_support = on
|
||||||
auto_report_temperatures = on
|
auto_report_temperatures = on
|
||||||
|
|
||||||
autotemp = on
|
autotemp = on
|
||||||
autotemp_min = 210
|
|
||||||
autotemp_max = 250
|
|
||||||
autotemp_factor = 0.1f
|
|
||||||
autotemp_oldweight = 0.98
|
autotemp_oldweight = 0.98
|
||||||
|
bed_check_interval = 5000
|
||||||
default_stepper_timeout_sec = 120
|
default_stepper_timeout_sec = 120
|
||||||
|
default_volumetric_extruder_limit = 0.00
|
||||||
disable_idle_x = on
|
disable_idle_x = on
|
||||||
disable_idle_y = on
|
disable_idle_y = on
|
||||||
disable_idle_z = on
|
disable_idle_z = on
|
||||||
disable_idle_e = on
|
disable_idle_e = on
|
||||||
e0_auto_fan_pin = -1
|
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
|
faster_gcode_parser = on
|
||||||
debug_flags_gcode = on
|
|
||||||
homing_bump_mm = { 5, 5, 2 }
|
homing_bump_mm = { 5, 5, 2 }
|
||||||
max_arc_segment_mm = 1.0
|
max_arc_segment_mm = 1.0
|
||||||
min_arc_segment_mm = 0.1
|
min_arc_segment_mm = 0.1
|
||||||
@@ -234,11 +237,11 @@ n_arc_correction = 25
|
|||||||
serial_overrun_protection = on
|
serial_overrun_protection = on
|
||||||
slowdown = on
|
slowdown = on
|
||||||
slowdown_divisor = 2
|
slowdown_divisor = 2
|
||||||
|
temp_sensor_bed = 0
|
||||||
|
thermal_protection_bed_hysteresis = 2
|
||||||
|
thermocouple_max_errors = 15
|
||||||
tx_buffer_size = 0
|
tx_buffer_size = 0
|
||||||
|
|
||||||
bed_check_interval = 5000
|
|
||||||
watch_bed_temp_increase = 2
|
watch_bed_temp_increase = 2
|
||||||
watch_bed_temp_period = 60
|
watch_bed_temp_period = 60
|
||||||
|
|
||||||
watch_temp_increase = 2
|
watch_temp_increase = 2
|
||||||
watch_temp_period = 40
|
watch_temp_period = 20
|
||||||
|
|||||||
@@ -22,23 +22,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for Atmel 8 bit AVR CPUs
|
* PWM print routines for Atmel 8 bit AVR CPUs
|
||||||
*
|
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
@@ -55,30 +39,30 @@
|
|||||||
#include "pinsDebug_Teensyduino.h"
|
#include "pinsDebug_Teensyduino.h"
|
||||||
// Can't use the "digitalPinToPort" function from the Teensyduino type IDEs
|
// Can't use the "digitalPinToPort" function from the Teensyduino type IDEs
|
||||||
// portModeRegister takes a different argument
|
// portModeRegister takes a different argument
|
||||||
#define digitalPinToTimer_DEBUG(P) digitalPinToTimer(P)
|
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
|
||||||
#define digitalPinToBitMask_DEBUG(P) digitalPinToBitMask(P)
|
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
|
||||||
#define digitalPinToPort_DEBUG(P) digitalPinToPort(P)
|
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
|
||||||
#define getValidPinMode(P) (*portModeRegister(P) & digitalPinToBitMask_DEBUG(P))
|
#define getValidPinMode(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin))
|
||||||
|
|
||||||
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
|
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
|
||||||
|
|
||||||
#include "pinsDebug_plus_70.h"
|
#include "pinsDebug_plus_70.h"
|
||||||
#define digitalPinToTimer_DEBUG(P) digitalPinToTimer_plus_70(P)
|
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer_plus_70(p)
|
||||||
#define digitalPinToBitMask_DEBUG(P) digitalPinToBitMask_plus_70(P)
|
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask_plus_70(p)
|
||||||
#define digitalPinToPort_DEBUG(P) digitalPinToPort_plus_70(P)
|
#define digitalPinToPort_DEBUG(p) digitalPinToPort_plus_70(p)
|
||||||
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
|
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define digitalPinToTimer_DEBUG(P) digitalPinToTimer(P)
|
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
|
||||||
#define digitalPinToBitMask_DEBUG(P) digitalPinToBitMask(P)
|
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
|
||||||
#define digitalPinToPort_DEBUG(P) digitalPinToPort(P)
|
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
|
||||||
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
|
bool getValidPinMode(pin_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); }
|
||||||
#define getPinByIndex(x) pgm_read_byte(&pin_array[x].pin)
|
#define getPinByIndex(p) pgm_read_byte(&pin_array[p].pin)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define isValidPin(P) (P >= 0 && P < NUMBER_PINS_TOTAL)
|
#define isValidPin(pin) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0)
|
||||||
#if AVR_ATmega1284_FAMILY
|
#if AVR_ATmega1284_FAMILY
|
||||||
#define isAnalogPin(P) WITHIN(P, analogInputToDigitalPin(7), analogInputToDigitalPin(0))
|
#define isAnalogPin(P) WITHIN(P, analogInputToDigitalPin(7), analogInputToDigitalPin(0))
|
||||||
#define digitalPinToAnalogIndex(P) int(isAnalogPin(P) ? (P) - analogInputToDigitalPin(7) : -1)
|
#define digitalPinToAnalogIndex(P) int(isAnalogPin(P) ? (P) - analogInputToDigitalPin(7) : -1)
|
||||||
@@ -88,11 +72,11 @@
|
|||||||
#define isAnalogPin(P) (_ANALOG1(P) || _ANALOG2(P))
|
#define isAnalogPin(P) (_ANALOG1(P) || _ANALOG2(P))
|
||||||
#define digitalPinToAnalogIndex(P) int(_ANALOG1(P) ? (P) - analogInputToDigitalPin(0) : _ANALOG2(P) ? (P) - analogInputToDigitalPin(8) + 8 : -1)
|
#define digitalPinToAnalogIndex(P) int(_ANALOG1(P) ? (P) - analogInputToDigitalPin(0) : _ANALOG2(P) ? (P) - analogInputToDigitalPin(8) + 8 : -1)
|
||||||
#endif
|
#endif
|
||||||
#define getPinByIndex(x) pgm_read_byte(&pin_array[x].pin)
|
#define getPinByIndex(p) pgm_read_byte(&pin_array[p].pin)
|
||||||
#define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
void printPinNameByIndex(const uint8_t index) {
|
void printPinNameByIndex(uint8_t x) {
|
||||||
PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[index].name);
|
PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name);
|
||||||
for (uint8_t y = 0; y < MAX_NAME_LENGTH; ++y) {
|
for (uint8_t y = 0; y < MAX_NAME_LENGTH; ++y) {
|
||||||
char temp_char = pgm_read_byte(name_mem_pointer + y);
|
char temp_char = pgm_read_byte(name_mem_pointer + y);
|
||||||
if (temp_char != 0)
|
if (temp_char != 0)
|
||||||
@@ -125,7 +109,7 @@ void printPinNameByIndex(const uint8_t index) {
|
|||||||
* Print a pin's PWM status.
|
* Print a pin's PWM status.
|
||||||
* Return true if it's currently a PWM pin.
|
* Return true if it's currently a PWM pin.
|
||||||
*/
|
*/
|
||||||
bool pwm_status(const uint8_t pin) {
|
bool pwm_status(uint8_t pin) {
|
||||||
char buffer[20]; // for the sprintf statements
|
char buffer[20]; // for the sprintf statements
|
||||||
|
|
||||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||||
@@ -292,7 +276,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
|||||||
if (TEST(*TMSK, TOIE)) err_prob_interrupt();
|
if (TEST(*TMSK, TOIE)) err_prob_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPWM(const uint8_t pin) {
|
void printPinPWM(uint8_t pin) {
|
||||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||||
|
|
||||||
#if ABTEST(0)
|
#if ABTEST(0)
|
||||||
@@ -402,7 +386,7 @@ void printPinPort(const pin_t pin) { // print port number
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
|
||||||
#undef ABTEST
|
#undef ABTEST
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
|||||||
|
|
||||||
// digitalPinToBitMask(pin) is OK
|
// digitalPinToBitMask(pin) is OK
|
||||||
|
|
||||||
#define digitalRead_mod(P) extDigitalRead(P) // Teensyduino's version of digitalRead doesn't
|
#define digitalRead_mod(p) extDigitalRead(p) // Teensyduino's version of digitalRead doesn't
|
||||||
// disable the PWMs so we can use it as is
|
// disable the PWMs so we can use it as is
|
||||||
|
|
||||||
// portModeRegister(pin) is OK
|
// portModeRegister(pin) is OK
|
||||||
|
|||||||
@@ -23,41 +23,43 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define SPI Pins: SCK, MISO, MOSI, SS
|
* 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__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
|
||||||
#define _PIN_SPI_SCK 13
|
#define AVR_SCK_PIN 13
|
||||||
#define _PIN_SPI_MISO 12
|
#define AVR_MISO_PIN 12
|
||||||
#define _PIN_SPI_MOSI 11
|
#define AVR_MOSI_PIN 11
|
||||||
#define _PIN_SPI_SS 10
|
#define AVR_SS_PIN 10
|
||||||
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
|
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
|
||||||
#define _PIN_SPI_SCK 7
|
#define AVR_SCK_PIN 7
|
||||||
#define _PIN_SPI_MISO 6
|
#define AVR_MISO_PIN 6
|
||||||
#define _PIN_SPI_MOSI 5
|
#define AVR_MOSI_PIN 5
|
||||||
#define _PIN_SPI_SS 4
|
#define AVR_SS_PIN 4
|
||||||
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define _PIN_SPI_SCK 52
|
#define AVR_SCK_PIN 52
|
||||||
#define _PIN_SPI_MISO 50
|
#define AVR_MISO_PIN 50
|
||||||
#define _PIN_SPI_MOSI 51
|
#define AVR_MOSI_PIN 51
|
||||||
#define _PIN_SPI_SS 53
|
#define AVR_SS_PIN 53
|
||||||
#elif defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
|
#elif defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
|
||||||
#define _PIN_SPI_SCK 21
|
#define AVR_SCK_PIN 21
|
||||||
#define _PIN_SPI_MISO 23
|
#define AVR_MISO_PIN 23
|
||||||
#define _PIN_SPI_MOSI 22
|
#define AVR_MOSI_PIN 22
|
||||||
#define _PIN_SPI_SS 20
|
#define AVR_SS_PIN 20
|
||||||
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||||
#define _PIN_SPI_SCK 10
|
#define AVR_SCK_PIN 10
|
||||||
#define _PIN_SPI_MISO 12
|
#define AVR_MISO_PIN 12
|
||||||
#define _PIN_SPI_MOSI 11
|
#define AVR_MOSI_PIN 11
|
||||||
#define _PIN_SPI_SS 16
|
#define AVR_SS_PIN 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SD_SCK_PIN
|
#ifndef SD_SCK_PIN
|
||||||
#define SD_SCK_PIN _PIN_SPI_SCK
|
#define SD_SCK_PIN AVR_SCK_PIN
|
||||||
#endif
|
#endif
|
||||||
#ifndef SD_MISO_PIN
|
#ifndef SD_MISO_PIN
|
||||||
#define SD_MISO_PIN _PIN_SPI_MISO
|
#define SD_MISO_PIN AVR_MISO_PIN
|
||||||
#endif
|
#endif
|
||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN _PIN_SPI_MOSI
|
#define SD_MOSI_PIN AVR_MOSI_PIN
|
||||||
|
#endif
|
||||||
|
#ifndef SD_SS_PIN
|
||||||
|
#define SD_SS_PIN AVR_SS_PIN
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ uint16_t MarlinHAL::adc_result;
|
|||||||
|
|
||||||
void MarlinHAL::init() {
|
void MarlinHAL::init() {
|
||||||
#if HAS_MEDIA
|
#if HAS_MEDIA
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
usb_task_init(); // Initialize the USB stack
|
usb_task_init(); // Initialize the USB stack
|
||||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||||
|
|||||||
@@ -35,9 +35,67 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
//
|
#include "../../core/serial_hook.h"
|
||||||
// Serial Ports
|
|
||||||
//
|
// ------------------------
|
||||||
|
// 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
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
#include "MarlinSerial.h"
|
||||||
#include "MarlinSerialUSB.h"
|
#include "MarlinSerialUSB.h"
|
||||||
|
|||||||
@@ -600,8 +600,9 @@
|
|||||||
OUT_WRITE(SPI_EEPROM1_CS_PIN, HIGH);
|
OUT_WRITE(SPI_EEPROM1_CS_PIN, HIGH);
|
||||||
OUT_WRITE(SPI_EEPROM2_CS_PIN, HIGH);
|
OUT_WRITE(SPI_EEPROM2_CS_PIN, HIGH);
|
||||||
OUT_WRITE(SPI_FLASH_CS_PIN, HIGH);
|
OUT_WRITE(SPI_FLASH_CS_PIN, HIGH);
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
WRITE(SD_SS_PIN, HIGH);
|
||||||
WRITE(SD_SS_PIN, LOW);
|
|
||||||
|
OUT_WRITE(SDSS, LOW);
|
||||||
|
|
||||||
PIO_Configure(
|
PIO_Configure(
|
||||||
g_APinDescription[SPI_PIN].pPort,
|
g_APinDescription[SPI_PIN].pPort,
|
||||||
@@ -766,7 +767,7 @@
|
|||||||
|
|
||||||
// Disable PIO on A26 and A27
|
// Disable PIO on A26 and A27
|
||||||
REG_PIOA_PDR = 0x0C000000;
|
REG_PIOA_PDR = 0x0C000000;
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
OUT_WRITE(SDSS, HIGH);
|
||||||
|
|
||||||
// Reset SPI0 (from sam lib)
|
// Reset SPI0 (from sam lib)
|
||||||
SPI0->SPI_CR = SPI_CR_SPIDIS;
|
SPI0->SPI_CR = SPI_CR_SPIDIS;
|
||||||
|
|||||||
@@ -33,21 +33,6 @@
|
|||||||
#include "../../core/types.h"
|
#include "../../core/types.h"
|
||||||
#include "../../core/serial_hook.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
|
// 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
|
// 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
|
// 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 *p1 = (uint32_t*)addrflash;
|
||||||
uint32_t *p2 = (uint32_t*)data;
|
uint32_t *p2 = (uint32_t*)data;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (i = 0; i < PageSize >> 2; i++) {
|
for (i =0; i<PageSize >> 2; i++) {
|
||||||
if (p1[i] != p2[i]) {
|
if (p1[i] != p2[i]) {
|
||||||
uint32_t delta = p1[i] ^ p2[i];
|
uint32_t delta = p1[i] ^ p2[i];
|
||||||
while (delta) {
|
while (delta) {
|
||||||
|
|||||||
@@ -19,26 +19,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for DUE
|
* Support routines for Due
|
||||||
*
|
*/
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
/**
|
||||||
* - getPinByIndex(index)
|
* Translation of routines & variables used by pinsDebug.h
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../shared/Marduino.h"
|
#include "../shared/Marduino.h"
|
||||||
@@ -76,20 +63,20 @@
|
|||||||
|
|
||||||
#define NUMBER_PINS_TOTAL PINS_COUNT
|
#define NUMBER_PINS_TOTAL PINS_COUNT
|
||||||
|
|
||||||
#define digitalRead_mod(P) extDigitalRead(P) // AVR digitalRead disabled PWM before it read the pin
|
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%02d"), P); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
|
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital
|
||||||
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
|
#define isValidPin(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
|
||||||
#define digitalPinToAnalogIndex(P) int(P - analogInputToDigitalPin(0))
|
#define digitalPinToAnalogIndex(p) int(p - analogInputToDigitalPin(0))
|
||||||
#define isAnalogPin(P) WITHIN(P, pin_t(analogInputToDigitalPin(0)), pin_t(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
|
#define isAnalogPin(P) WITHIN(P, pin_t(analogInputToDigitalPin(0)), pin_t(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
|
||||||
#define pwm_status(P) (((g_pinStatus[P] & 0xF) == PIN_STATUS_PWM) && \
|
#define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \
|
||||||
((g_APinDescription[P].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM))
|
((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM))
|
||||||
#define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
bool getValidPinMode(const pin_t pin) { // 1: output, 0: input
|
bool getValidPinMode(int8_t pin) { // 1: output, 0: input
|
||||||
volatile Pio* port = g_APinDescription[pin].pPort;
|
volatile Pio* port = g_APinDescription[pin].pPort;
|
||||||
uint32_t mask = g_APinDescription[pin].ulPin;
|
uint32_t mask = g_APinDescription[pin].ulPin;
|
||||||
uint8_t pin_status = g_pinStatus[pin] & 0xF;
|
uint8_t pin_status = g_pinStatus[pin] & 0xF;
|
||||||
@@ -98,7 +85,7 @@ bool getValidPinMode(const pin_t pin) { // 1: output, 0: input
|
|||||||
|| pwm_status(pin));
|
|| pwm_status(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPWM(const int32_t pin) {
|
void printPinPWM(int32_t pin) {
|
||||||
if (pwm_status(pin)) {
|
if (pwm_status(pin)) {
|
||||||
uint32_t chan = g_APinDescription[pin].ulPWMChannel;
|
uint32_t chan = g_APinDescription[pin].ulPWMChannel;
|
||||||
SERIAL_ECHOPGM("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
|
SERIAL_ECHOPGM("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
|
||||||
|
|||||||
@@ -26,36 +26,39 @@
|
|||||||
*
|
*
|
||||||
* Available chip select pins for HW SPI are 4 10 52 77 87
|
* Available chip select pins for HW SPI are 4 10 52 77 87
|
||||||
*/
|
*/
|
||||||
#if SD_SS_PIN == 4 || SD_SS_PIN == 10 || SD_SS_PIN == 52 || SD_SS_PIN == 77 || SD_SS_PIN == 87
|
#if SDSS == 4 || SDSS == 10 || SDSS == 52 || SDSS == 77 || SDSS == 87
|
||||||
#define SD_SCK_PIN 76
|
#if SDSS == 4
|
||||||
#define SD_MISO_PIN 74
|
#define SPI_PIN 87
|
||||||
#define SD_MOSI_PIN 75
|
#define SPI_CHAN 1
|
||||||
#endif
|
#elif SDSS == 10
|
||||||
|
#define SPI_PIN 77
|
||||||
#if SD_SS_PIN == 4
|
#define SPI_CHAN 0
|
||||||
#define SPI_PIN 87
|
#elif SDSS == 52
|
||||||
#define SPI_CHAN 1
|
#define SPI_PIN 86
|
||||||
#elif SD_SS_PIN == 10
|
#define SPI_CHAN 2
|
||||||
#define SPI_PIN 77
|
#elif SDSS == 77
|
||||||
#define SPI_CHAN 0
|
#define SPI_PIN 77
|
||||||
#elif SD_SS_PIN == 52
|
#define SPI_CHAN 0
|
||||||
#define SPI_PIN 86
|
#else
|
||||||
#define SPI_CHAN 2
|
#define SPI_PIN 87
|
||||||
#elif SD_SS_PIN == 77
|
#define SPI_CHAN 1
|
||||||
#define SPI_PIN 77
|
#endif
|
||||||
#define SPI_CHAN 0
|
#define SD_SCK_PIN 76
|
||||||
#elif SD_SS_PIN == 87
|
#define SD_MISO_PIN 74
|
||||||
#define SPI_PIN 87
|
#define SD_MOSI_PIN 75
|
||||||
#define SPI_CHAN 1
|
|
||||||
#else
|
#else
|
||||||
|
// defaults
|
||||||
#define SOFTWARE_SPI
|
#define SOFTWARE_SPI
|
||||||
#ifndef SD_SCK_PIN
|
#ifndef SD_SCK_PIN
|
||||||
#define SD_SCK_PIN 52
|
#define SD_SCK_PIN 52
|
||||||
#endif
|
#endif
|
||||||
#ifndef SD_MISO_PIN
|
#ifndef SD_MISO_PIN
|
||||||
#define SD_MISO_PIN 50
|
#define SD_MISO_PIN 50
|
||||||
#endif
|
#endif
|
||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN 51
|
#define SD_MOSI_PIN 51
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* A.28, A.29, B.21, C.26, C.29 */
|
||||||
|
#define SD_SS_PIN SDSS
|
||||||
|
|||||||
@@ -37,10 +37,6 @@
|
|||||||
// Set pin as output
|
// Set pin as output
|
||||||
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT)
|
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT)
|
||||||
|
|
||||||
// TODO: Store set modes in an array and use those to get the mode
|
|
||||||
#define _IS_OUTPUT(IO) true
|
|
||||||
#define _IS_INPUT(IO) true
|
|
||||||
|
|
||||||
// Set pin as input with pullup mode
|
// Set pin as input with pullup mode
|
||||||
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
|
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
|
||||||
|
|
||||||
@@ -74,9 +70,6 @@
|
|||||||
// Set pin as output and init
|
// Set pin as output and init
|
||||||
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||||
|
|
||||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
|
||||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||||
|
|||||||
@@ -22,15 +22,11 @@
|
|||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
#include <WiFi.h>
|
|
||||||
|
|
||||||
#undef ENABLED
|
|
||||||
#undef DISABLED
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ALL(WIFISUPPORT, OTASUPPORT)
|
#if ALL(WIFISUPPORT, OTASUPPORT)
|
||||||
|
|
||||||
|
#include <WiFi.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#error "PINS_DEBUGGING is not yet supported for ESP32!"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pins Debugging for ESP32
|
|
||||||
*
|
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
|
||||||
|
|
||||||
#define digitalRead_mod(P) extDigitalRead(P)
|
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%02d"), P); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
|
||||||
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
|
|
||||||
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
|
|
||||||
#define digitalPinToAnalogIndex(P) int(P - analogInputToDigitalPin(0))
|
|
||||||
#define isAnalogPin(P) WITHIN(P, pin_t(analogInputToDigitalPin(0)), pin_t(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
|
|
||||||
bool pwm_status(const pin_t) { return false; }
|
|
||||||
|
|
||||||
void printPinPort(const pin_t) {}
|
|
||||||
|
|
||||||
static bool getValidPinMode(const pin_t pin) {
|
|
||||||
return isValidPin(pin) && !IS_INPUT(pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void printPinPWM(const int32_t pin) {
|
|
||||||
if (pwm_status(pin)) {
|
|
||||||
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
|
||||||
//SERIAL_ECHOPGM("PWM = ", duty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,16 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define PIN_SPI_SCK 18
|
#define SD_SS_PIN SDSS
|
||||||
#define PIN_SPI_MISO 19
|
#define SD_SCK_PIN 18
|
||||||
#define PIN_SPI_MOSI 23
|
#define SD_MISO_PIN 19
|
||||||
|
#define SD_MOSI_PIN 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,12 +21,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
|
#include "../../core/serial.h"
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ENABLED(WIFISUPPORT)
|
#if ENABLED(WIFISUPPORT)
|
||||||
|
|
||||||
#include "../../core/serial.h"
|
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
|
|||||||
@@ -30,18 +30,69 @@
|
|||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
#include "../../core/macros.h"
|
||||||
#include "../shared/Marduino.h"
|
#include "../shared/Marduino.h"
|
||||||
#include "../shared/math_32bit.h"
|
#include "../shared/math_32bit.h"
|
||||||
#include "../shared/HAL_SPI.h"
|
#include "../shared/HAL_SPI.h"
|
||||||
|
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Serial Ports
|
// Serial Ports
|
||||||
//
|
//
|
||||||
|
#define _MSERIAL(X) MSerial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define NUM_UARTS 4
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
#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
|
||||||
|
|
||||||
//
|
//
|
||||||
// Emergency Parser
|
// Emergency Parser
|
||||||
|
|||||||
@@ -24,14 +24,6 @@
|
|||||||
#include "../../core/serial_hook.h"
|
#include "../../core/serial_hook.h"
|
||||||
#include <drivers/usart/Usart.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
|
// Optionally set uart IRQ priority to reduce overflow errors
|
||||||
//#define UART_RX_IRQ_PRIO 1
|
//#define UART_RX_IRQ_PRIO 1
|
||||||
//#define UART_TX_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`.)
|
- 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.
|
- 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))
|
3. Determine your board's application start address (see [below](#finding-the-application-start-address))
|
||||||
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.
|
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.
|
||||||
|
|
||||||
### Finding the application start address
|
### Finding the application start address
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#define _HC32_APP_CONFIG_H_
|
#define _HC32_APP_CONFIG_H_
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
#include "sysclock.h"
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// dev mode
|
// dev mode
|
||||||
@@ -65,8 +64,12 @@
|
|||||||
// redirect printf to host serial
|
// redirect printf to host serial
|
||||||
#define REDIRECT_PRINTF_TO_SERIAL 1
|
#define REDIRECT_PRINTF_TO_SERIAL 1
|
||||||
|
|
||||||
// F_CPU is F_HCLK, as that's the main CPU core's clock.
|
// F_CPU must be known at compile time, but on HC32F460 it's not.
|
||||||
// see 'sysclock.h' for more information.
|
// Thus we assume HCLK to be 200MHz, as that's what is configured in
|
||||||
#define F_CPU F_HCLK
|
// 'core_hook_sysclock_init' in 'sysclock.cpp'.
|
||||||
|
// If you face issues with this assumption, please double-check with the values
|
||||||
|
// printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
|
||||||
|
// see also: HAL_TIMER_RATE in timers.h
|
||||||
|
#define F_CPU 200000000 // 200MHz HCLK
|
||||||
|
|
||||||
#endif // _HC32_APP_CONFIG_H_
|
#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."
|
#error "SERIAL_DMA requires USART_RX_DMA_SUPPORT to be enabled in the arduino core."
|
||||||
#endif
|
#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.
|
// 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).
|
// 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)
|
#if ENABLED(EMERGENCY_PARSER) && ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 2, 0)
|
||||||
|
|||||||
@@ -18,47 +18,41 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
|
||||||
* Pins Debugging for HC32
|
|
||||||
*
|
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include <drivers/timera/timera_pwm.h>
|
#include <drivers/timera/timera_pwm.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Translation of routines & variables used by pinsDebug.h
|
||||||
|
//
|
||||||
#ifndef BOARD_NR_GPIO_PINS
|
#ifndef BOARD_NR_GPIO_PINS
|
||||||
#error "Expected BOARD_NR_GPIO_PINS not found."
|
#error "Expected BOARD_NR_GPIO_PINS not found."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
|
#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
|
||||||
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
|
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
|
||||||
#define isValidPin(P) IS_GPIO_PIN(P)
|
#define isValidPin(pin) IS_GPIO_PIN(pin)
|
||||||
|
|
||||||
// Note: pin_array is defined in `Marlin/src/pins/pinsDebug.h`, and since this file is included
|
// Note: pin_array is defined in `Marlin/src/pins/pinsDebug.h`, and since this file is included
|
||||||
// after it, it is available in this file as well.
|
// after it, it is available in this file as well.
|
||||||
#define getPinByIndex(x) pin_t(pin_array[x].pin)
|
#define getPinByIndex(p) pin_t(pin_array[p].pin)
|
||||||
#define digitalRead_mod(P) extDigitalRead(P)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
|
#define printPinNumber(p) \
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(P)); SERIAL_ECHO(buffer); }while(0)
|
do { \
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); \
|
||||||
|
SERIAL_ECHO(buffer); \
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
} while (0)
|
||||||
|
#define printPinAnalog(p) \
|
||||||
|
do { \
|
||||||
|
sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); \
|
||||||
|
SERIAL_ECHO(buffer); \
|
||||||
|
} while (0)
|
||||||
|
#define PRINT_PORT(p) printPinPort(p)
|
||||||
|
#define printPinNameByIndex(x) \
|
||||||
|
do { \
|
||||||
|
sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); \
|
||||||
|
SERIAL_ECHO(buffer); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define MULTI_NAME_PAD 21 // Space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 21 // Space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
@@ -77,13 +71,13 @@
|
|||||||
#define M43_NEVER_TOUCH(Q) (IS_HOST_USART_PIN(Q) || IS_OSC_PIN(Q))
|
#define M43_NEVER_TOUCH(Q) (IS_HOST_USART_PIN(Q) || IS_OSC_PIN(Q))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int8_t digitalPinToAnalogIndex(const pin_t pin) {
|
static int8_t digitalPinToAnalogIndex(pin_t pin) {
|
||||||
if (!isValidPin(pin)) return -1;
|
if (!isValidPin(pin)) return -1;
|
||||||
const int8_t adc_channel = int8_t(PIN_MAP[pin].adc_info.channel);
|
const int8_t adc_channel = int8_t(PIN_MAP[pin].adc_info.channel);
|
||||||
return pin_t(adc_channel);
|
return pin_t(adc_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAnalogPin(pin_t pin) {
|
static bool isAnalogPin(pin_t pin) {
|
||||||
if (!isValidPin(pin)) return false;
|
if (!isValidPin(pin)) return false;
|
||||||
|
|
||||||
if (PIN_MAP[pin].adc_info.channel != ADC_PIN_INVALID)
|
if (PIN_MAP[pin].adc_info.channel != ADC_PIN_INVALID)
|
||||||
@@ -92,12 +86,12 @@ bool isAnalogPin(pin_t pin) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getValidPinMode(const pin_t pin) {
|
static bool getValidPinMode(const pin_t pin) {
|
||||||
return isValidPin(pin) && !IS_INPUT(pin);
|
return isValidPin(pin) && !IS_INPUT(pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getPinIsDigitalByIndex(const int16_t index) {
|
static bool getPinIsDigitalByIndex(const int16_t array_pin) {
|
||||||
const pin_t pin = getPinByIndex(index);
|
const pin_t pin = getPinByIndex(array_pin);
|
||||||
return (!isAnalogPin(pin));
|
return (!isAnalogPin(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,144 +26,64 @@
|
|||||||
|
|
||||||
#ifdef ARDUINO_ARCH_HC32
|
#ifdef ARDUINO_ARCH_HC32
|
||||||
|
|
||||||
|
// Get BOARD_XTAL_FREQUENCY from configuration / pins
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "sysclock.h"
|
|
||||||
|
|
||||||
#include <core_hooks.h>
|
#include <core_hooks.h>
|
||||||
#include <drivers/sysclock/sysclock_util.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() {
|
void core_hook_sysclock_init() {
|
||||||
// Set wait cycles, as we are about to switch to 200 MHz HCLK
|
// Set wait cycles, as we are about to switch to 200 MHz HCLK
|
||||||
sysclock_configure_flash_wait_cycles();
|
sysclock_configure_flash_wait_cycles();
|
||||||
sysclock_configure_sram_wait_cycles();
|
sysclock_configure_sram_wait_cycles();
|
||||||
|
|
||||||
// Select MPLL input frequency based on clock availability
|
// Configure MPLLp to 200 MHz output, with different settings depending on XTAL availability
|
||||||
#if BOARD_XTAL_FREQUENCY == 8000000 || BOARD_XTAL_FREQUENCY == 16000000 // 8 MHz or 16 MHz XTAL
|
#if BOARD_XTAL_FREQUENCY == 8000000 // 8 MHz XTAL
|
||||||
constexpr uint32_t mpll_input_clock = BOARD_XTAL_FREQUENCY;
|
// - 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_xtal();
|
||||||
|
sysclock_configure_mpll(ClkPllSrcXTAL, &pllConf);
|
||||||
|
|
||||||
#if BOARD_XTAL_FREQUENCY == 16000000
|
#elif BOARD_XTAL_FREQUENCY == 16000000 // 16 MHz XTAL
|
||||||
#warning "HC32F460 with 16 MHz XTAL has not been tested."
|
// - M = 1 => 16 MHz / 1 = 16 MHz
|
||||||
#endif
|
// - 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."
|
||||||
|
|
||||||
#else // HRC (16 MHz)
|
#else // HRC (16 MHz)
|
||||||
|
// - M = 1 => 16 MHz / 1 = 16 MHz
|
||||||
constexpr uint32_t mpll_input_clock = 16000000;
|
// - 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
|
||||||
|
};
|
||||||
sysclock_configure_hrc();
|
sysclock_configure_hrc();
|
||||||
|
sysclock_configure_mpll(ClkPllSrcHRC, &pllConf);
|
||||||
|
|
||||||
// HRC could have been configured by ICG to 20 MHz
|
// HRC could have been configured by ICG to 20 MHz
|
||||||
// TODO: handle gracefully if HRC is not 16 MHz
|
// TODO: handle gracefully if HRC is not 16 MHz
|
||||||
@@ -171,56 +91,29 @@ void core_hook_sysclock_init() {
|
|||||||
panic("HRC is not 16 MHz");
|
panic("HRC is not 16 MHz");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOARD_XTAL_FREQUENCY)
|
#ifdef BOARD_XTAL_FREQUENCY
|
||||||
#warning "No valid XTAL frequency defined, falling back to HRC."
|
#warning "No valid XTAL frequency defined, falling back to HRC."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Automagically calculate MPLL configuration
|
// sysclk is now configured according to F_CPU (i.e., 200MHz PLL output)
|
||||||
constexpr stc_clk_mpll_cfg_t pllConf = get_mpll_config(mpll_input_clock, F_SYSTEM_CLOCK);
|
const uint32_t sysclock = F_CPU;
|
||||||
static_assert(pllConf.pllmDiv != 0 && pllConf.plln != 0 && pllConf.PllpDiv != 0, "MPLL auto-configuration failed");
|
|
||||||
sysclock_configure_mpll(ClkPllSrcXTAL, &pllConf);
|
|
||||||
|
|
||||||
// Setup clock divisors
|
// Setup clock divisors for sysclk = 200 MHz
|
||||||
|
// Note: PCLK1 is used for step+temp timers, and need to be kept at 50 MHz (until there is a better solution)
|
||||||
constexpr stc_clk_sysclk_cfg_t sysClkConf = {
|
constexpr stc_clk_sysclk_cfg_t sysClkConf = {
|
||||||
.enHclkDiv = get_division_factor<F_SYSTEM_CLOCK, F_HCLK>(),
|
.enHclkDiv = ClkSysclkDiv1, // HCLK = 200 MHz (CPU)
|
||||||
.enExclkDiv = get_division_factor<F_SYSTEM_CLOCK, F_EXCLK>(),
|
.enExclkDiv = ClkSysclkDiv2, // EXCLK = 100 MHz (SDIO)
|
||||||
.enPclk0Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK0>(),
|
.enPclk0Div = ClkSysclkDiv2, // PCLK0 = 100 MHz (Timer6 (not used))
|
||||||
.enPclk1Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK1>(),
|
.enPclk1Div = ClkSysclkDiv4, // PCLK1 = 50 MHz (USART, SPI, I2S, Timer0 (step+temp), TimerA (Servo))
|
||||||
.enPclk2Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK2>(),
|
.enPclk2Div = ClkSysclkDiv8, // PCLK2 = 25 MHz (ADC)
|
||||||
.enPclk3Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK3>(),
|
.enPclk3Div = ClkSysclkDiv8, // PCLK3 = 25 MHz (I2C, WDT)
|
||||||
.enPclk4Div = get_division_factor<F_SYSTEM_CLOCK, F_PCLK4>(),
|
.enPclk4Div = ClkSysclkDiv2, // PCLK4 = 100 MHz (ADC ctl)
|
||||||
};
|
};
|
||||||
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)
|
#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<
|
assert_system_clocks_valid<
|
||||||
F_SYSTEM_CLOCK,
|
sysclock,
|
||||||
sysClkConf.enHclkDiv,
|
sysClkConf.enHclkDiv,
|
||||||
sysClkConf.enPclk0Div,
|
sysClkConf.enPclk0Div,
|
||||||
sysClkConf.enPclk1Div,
|
sysClkConf.enPclk1Div,
|
||||||
@@ -229,14 +122,18 @@ void core_hook_sysclock_init() {
|
|||||||
sysClkConf.enPclk4Div,
|
sysClkConf.enPclk4Div,
|
||||||
sysClkConf.enExclkDiv
|
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
|
#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
|
#endif // ARDUINO_ARCH_HC32
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,7 +20,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <Timer0.h>
|
#include <Timer0.h>
|
||||||
#include "sysclock.h"
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Timer Types
|
// Timer Types
|
||||||
@@ -43,15 +42,17 @@ extern Timer0 step_timer;
|
|||||||
* HAL_TIMER_RATE must be known at compile time since it's used to calculate
|
* HAL_TIMER_RATE must be known at compile time since it's used to calculate
|
||||||
* STEPPER_TIMER_RATE, which is used in 'constexpr' calculations.
|
* STEPPER_TIMER_RATE, which is used in 'constexpr' calculations.
|
||||||
* On the HC32F460 the timer rate depends on PCLK1, which is derived from the
|
* On the HC32F460 the timer rate depends on PCLK1, which is derived from the
|
||||||
* system clock configured at runtime.
|
* system clock configured at runtime. As a workaround, we use the existing
|
||||||
* Thus we use the 'F_PCLK1' constant defined in 'sysclock.h'.
|
* 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'.
|
||||||
*
|
*
|
||||||
* See https://github.com/MarlinFirmware/Marlin/pull/27099 for more information.
|
* If you face issues with this assumption, please double-check with the values
|
||||||
|
* printed by 'MarlinHAL::HAL_clock_frequencies_dump'.
|
||||||
*
|
*
|
||||||
* NOTE: If the 'constexpr' requirement is ever lifted, TIMER0_BASE_FREQUENCY could
|
* TODO: If the 'constexpr' requirement is ever lifted, use TIMER0_BASE_FREQUENCY instead
|
||||||
* be used instead. Tho this would probably not make any noticable difference.
|
|
||||||
*/
|
*/
|
||||||
#define HAL_TIMER_RATE F_PCLK1
|
#define HAL_TIMER_RATE (F_CPU / 4) // i.e., 50MHz
|
||||||
|
//#define HAL_TIMER_RATE TIMER0_BASE_FREQUENCY
|
||||||
|
|
||||||
// Temperature timer
|
// Temperature timer
|
||||||
#define TEMP_TIMER_NUM (&temp_timer)
|
#define TEMP_TIMER_NUM (&temp_timer)
|
||||||
|
|||||||
@@ -37,29 +37,29 @@ constexpr uint8_t NUM_ANALOG_INPUTS = 16;
|
|||||||
constexpr uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS;
|
constexpr uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS;
|
||||||
|
|
||||||
// Get the digital pin for an analog index
|
// Get the digital pin for an analog index
|
||||||
constexpr pin_t analogInputToDigitalPin(const int8_t a) {
|
constexpr pin_t analogInputToDigitalPin(const int8_t p) {
|
||||||
return (WITHIN(a, 0, NUM_ANALOG_INPUTS - 1) ? analog_offset + a : P_NC);
|
return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? analog_offset + p : P_NC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the analog index for a digital pin
|
// Get the analog index for a digital pin
|
||||||
constexpr int8_t digitalPinToAnalogIndex(const pin_t pin) {
|
constexpr int8_t digitalPinToAnalogIndex(const pin_t p) {
|
||||||
return (WITHIN(pin, analog_offset, NUM_DIGITAL_PINS - 1) ? pin - analog_offset : P_NC);
|
return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the index of a pin number
|
// Return the index of a pin number
|
||||||
constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; }
|
constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; }
|
||||||
|
|
||||||
// Test whether the pin is valid
|
// Test whether the pin is valid
|
||||||
constexpr bool isValidPin(const pin_t pin) { return WITHIN(pin, 0, NUM_DIGITAL_PINS - 1); }
|
constexpr bool isValidPin(const pin_t p) { return WITHIN(p, 0, NUM_DIGITAL_PINS); }
|
||||||
|
|
||||||
// Test whether the pin is PWM
|
// Test whether the pin is PWM
|
||||||
constexpr bool PWM_PIN(const pin_t) { return false; }
|
constexpr bool PWM_PIN(const pin_t p) { return false; }
|
||||||
|
|
||||||
// Test whether the pin is interruptible
|
// Test whether the pin is interruptible
|
||||||
constexpr bool INTERRUPT_PIN(const pin_t) { return false; }
|
constexpr bool INTERRUPT_PIN(const pin_t p) { return false; }
|
||||||
|
|
||||||
// Get the pin number at the given index
|
// Get the pin number at the given index
|
||||||
constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) { return pin_t(index); }
|
constexpr pin_t GET_PIN_MAP_PIN(const int16_t ind) { return ind; }
|
||||||
|
|
||||||
// Parse a G-code word into a pin index
|
// Parse a G-code word into a pin index
|
||||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||||
|
|||||||
@@ -19,46 +19,26 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for Linux Native
|
* Support routines for X86_64
|
||||||
*
|
*/
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
/**
|
||||||
* - getPinByIndex(index)
|
* Translation of routines & variables used by pinsDebug.h
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0)
|
||||||
|
#define digitalRead_mod(p) digitalRead(p)
|
||||||
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
|
||||||
|
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
|
|
||||||
// active ADC function/mode/code values for PINSEL registers
|
// active ADC function/mode/code values for PINSEL registers
|
||||||
constexpr int8_t ADC_pin_mode(const pin_t) { return -1; }
|
constexpr int8_t ADC_pin_mode(pin_t pin) { return -1; }
|
||||||
|
|
||||||
// The pin and index are the same on this platform
|
|
||||||
bool getPinIsDigitalByIndex(const pin_t pin) {
|
|
||||||
return (!isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0)
|
|
||||||
|
|
||||||
#define digitalRead_mod(P) digitalRead(P)
|
|
||||||
|
|
||||||
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; }
|
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; }
|
||||||
|
|
||||||
@@ -70,11 +50,11 @@ bool getValidPinMode(const pin_t pin) {
|
|||||||
return (Gpio::getMode(pin) != 0); // Input/output state
|
return (Gpio::getMode(pin) != 0); // Input/output state
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPWM(const pin_t) {}
|
bool getPinIsDigitalByIndex(const pin_t pin) {
|
||||||
|
return (!isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
|
||||||
|
}
|
||||||
|
|
||||||
|
void printPinPWM(const pin_t pin) {}
|
||||||
bool pwm_status(const pin_t) { return false; }
|
bool pwm_status(const pin_t) { return false; }
|
||||||
|
|
||||||
void printPinPort(const pin_t) {}
|
void printPinPort(const pin_t) {}
|
||||||
|
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
|
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
|
|||||||
@@ -38,3 +38,9 @@
|
|||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN 52
|
#define SD_MOSI_PIN 52
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SD_SS_PIN
|
||||||
|
#define SD_SS_PIN 53
|
||||||
|
#endif
|
||||||
|
#ifndef SDSS
|
||||||
|
#define SDSS SD_SS_PIN
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#include <CDCSerial.h>
|
#include <CDCSerial.h>
|
||||||
#include <usb/mscuser.h>
|
#include <usb/mscuser.h>
|
||||||
|
|
||||||
|
DefaultSerial1 USBSerial(false, UsbSerial);
|
||||||
|
|
||||||
uint32_t MarlinHAL::adc_result = 0;
|
uint32_t MarlinHAL::adc_result = 0;
|
||||||
pin_t MarlinHAL::adc_pin = 0;
|
pin_t MarlinHAL::adc_pin = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,72 @@ extern "C" volatile uint32_t _millis;
|
|||||||
#include "../shared/math_32bit.h"
|
#include "../shared/math_32bit.h"
|
||||||
#include "../shared/HAL_SPI.h"
|
#include "../shared/HAL_SPI.h"
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
#include <adc.h>
|
#include <adc.h>
|
||||||
#include <pinmapping.h>
|
#include <pinmapping.h>
|
||||||
|
#include <CDCSerial.h>
|
||||||
|
|
||||||
//
|
// ------------------------
|
||||||
// Serial Ports
|
// Serial ports
|
||||||
//
|
// ------------------------
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
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
|
||||||
|
|
||||||
//
|
//
|
||||||
// Interrupts
|
// Interrupts
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
DefaultSerial1 USBSerial(false, UsbSerial);
|
|
||||||
|
|
||||||
#if USING_HW_SERIAL0
|
#if USING_HW_SERIAL0
|
||||||
MarlinSerial _MSerial0(LPC_UART0);
|
MarlinSerial _MSerial0(LPC_UART0);
|
||||||
MSerialT MSerial0(true, _MSerial0);
|
MSerialT MSerial0(true, _MSerial0);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <CDCSerial.h>
|
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
|
||||||
@@ -31,18 +30,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "../../core/serial_hook.h"
|
#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> {
|
class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
|
||||||
public:
|
public:
|
||||||
MarlinSerial(LPC_UART_TypeDef *UARTx) : HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE>(UARTx) { }
|
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)
|
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
||||||
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
#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) \
|
#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_PIN, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||||
#error "Serial port pins (1) conflict with LCD pins!"
|
#error "Serial port pins (1) conflict with LCD pins!"
|
||||||
#endif
|
#endif
|
||||||
#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!"
|
#error "SCL0 overlaps with Encoder Button!"
|
||||||
#elif IS_SCL0(SD_SS_PIN)
|
#elif IS_SCL0(SD_SS_PIN)
|
||||||
#error "SCL0 overlaps with SD_SS_PIN!"
|
#error "SCL0 overlaps with SD_SS_PIN!"
|
||||||
#elif IS_SCL0(LCD_SDSS_PIN)
|
#elif IS_SCL0(LCD_SDSS)
|
||||||
#error "SCL0 overlaps with LCD_SDSS_PIN!"
|
#error "SCL0 overlaps with LCD_SDSS!"
|
||||||
#endif
|
#endif
|
||||||
#undef PIN_IS_SDA0
|
#undef PIN_IS_SDA0
|
||||||
#undef IS_SCL0
|
#undef IS_SCL0
|
||||||
|
|||||||
@@ -19,35 +19,22 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for LPC1768/9
|
* Support routines for LPC1768
|
||||||
*
|
*/
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
/**
|
||||||
* - getPinByIndex(index)
|
* Translation of routines & variables used by pinsDebug.h
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0)
|
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0)
|
||||||
#define digitalRead_mod(P) extDigitalRead(P)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(P), LPC176x::pin_bit(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(p), LPC176x::pin_bit(p)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR("_A%d "), LPC176x::pin_get_adc_channel(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR("_A%d "), LPC176x::pin_get_adc_channel(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 17 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 17 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
//#define SD_SCK_PIN P0_07
|
//#define SD_SCK_PIN P0_07
|
||||||
//#define SD_MISO_PIN P0_08
|
//#define SD_MISO_PIN P0_08
|
||||||
//#define SD_MOSI_PIN P0_09
|
//#define SD_MOSI_PIN P0_09
|
||||||
|
//#define SD_SS_PIN P0_06
|
||||||
|
|
||||||
// External SD
|
// External SD
|
||||||
#ifndef SD_SCK_PIN
|
#ifndef SD_SCK_PIN
|
||||||
@@ -43,3 +44,10 @@
|
|||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN P0_18
|
#define SD_MOSI_PIN P0_18
|
||||||
#endif
|
#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:'
|
# 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
|
# 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 ctypes import windll
|
||||||
from pathlib import PureWindowsPath
|
from pathlib import PureWindowsPath
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,37 @@ extern MSerialT serial_stream_2;
|
|||||||
extern MSerialT serial_stream_3;
|
extern MSerialT serial_stream_3;
|
||||||
|
|
||||||
#define _MSERIAL(X) serial_stream_##X
|
#define _MSERIAL(X) serial_stream_##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
|
||||||
#define SERIAL_INDEX_MIN 0
|
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define SERIAL_INDEX_MAX 3
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#include "../shared/serial_ports.h"
|
#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
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Interrupts
|
// Interrupts
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "pinsDebug.h"
|
#include "pinsDebug.h"
|
||||||
|
|
||||||
int8_t ADC_pin_mode(const pin_t) { return -1; }
|
int8_t ADC_pin_mode(pin_t pin) { return -1; }
|
||||||
|
|
||||||
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; }
|
int8_t get_pin_mode(const pin_t pin) { return isValidPin(pin) ? 0 : -1; }
|
||||||
|
|
||||||
@@ -37,7 +37,6 @@ bool getValidPinMode(const pin_t pin) {
|
|||||||
return (Gpio::getMode(pin) != 0); // Input/output state
|
return (Gpio::getMode(pin) != 0); // Input/output state
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pin and index are the same on this platform
|
|
||||||
bool getPinIsDigitalByIndex(const pin_t pin) {
|
bool getPinIsDigitalByIndex(const pin_t pin) {
|
||||||
return !isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin);
|
return !isAnalogPin(pin) || get_pin_mode(pin) != ADC_pin_mode(pin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,43 +19,30 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support routines for X86_64
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for x86_64
|
* Translation of routines & variables used by pinsDebug.h
|
||||||
*
|
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
|
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0 ? 1 : 0)
|
||||||
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0)
|
#define digitalRead_mod(p) digitalRead(p)
|
||||||
#define digitalRead_mod(P) digitalRead(P)
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// Active ADC function/mode/code values for PINSEL registers
|
// Active ADC function/mode/code values for PINSEL registers
|
||||||
int8_t ADC_pin_mode(const pin_t);
|
int8_t ADC_pin_mode(pin_t pin);
|
||||||
int8_t get_pin_mode(const pin_t);
|
int8_t get_pin_mode(const pin_t pin);
|
||||||
bool getValidPinMode(const pin_t);
|
bool getValidPinMode(const pin_t pin);
|
||||||
bool getPinIsDigitalByIndex(const pin_t);
|
bool getPinIsDigitalByIndex(const pin_t pin);
|
||||||
void printPinPort(const pin_t);
|
void printPinPort(const pin_t);
|
||||||
void printPinPWM(const pin_t);
|
void printPinPWM(const pin_t);
|
||||||
bool pwm_status(const pin_t);
|
bool pwm_status(const pin_t);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
//#define SD_SCK_PIN P0_07
|
//#define SD_SCK_PIN P0_07
|
||||||
//#define SD_MISO_PIN P0_08
|
//#define SD_MISO_PIN P0_08
|
||||||
//#define SD_MOSI_PIN P0_09
|
//#define SD_MOSI_PIN P0_09
|
||||||
|
//#define SD_SS_PIN P0_06
|
||||||
|
|
||||||
// External SD
|
// External SD
|
||||||
#ifndef SD_SCK_PIN
|
#ifndef SD_SCK_PIN
|
||||||
@@ -43,3 +44,9 @@
|
|||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN 52
|
#define SD_MOSI_PIN 52
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SD_SS_PIN
|
||||||
|
#define SD_SS_PIN 53
|
||||||
|
#endif
|
||||||
|
#ifndef SDSS
|
||||||
|
#define SDSS SD_SS_PIN
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,185 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "HAL.h"
|
|
||||||
//#include "usb_serial.h"
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
#include "../shared/Delay.h"
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "pico/bootrom.h"
|
|
||||||
#include "hardware/watchdog.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#if HAS_SD_HOST_DRIVE
|
|
||||||
#include "msc_sd.h"
|
|
||||||
#include "usbd_cdc_if.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public Variables
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
volatile uint16_t adc_result;
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public functions
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
|
||||||
|
|
||||||
// HAL initialization task
|
|
||||||
void MarlinHAL::init() {
|
|
||||||
// Ensure F_CPU is a constant expression.
|
|
||||||
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
|
|
||||||
// So better safe than sorry here.
|
|
||||||
constexpr int cpuFreq = F_CPU;
|
|
||||||
UNUSED(cpuFreq);
|
|
||||||
|
|
||||||
#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)
|
|
||||||
OUT_WRITE(LED_PIN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(SRAM_EEPROM_EMULATION)
|
|
||||||
// __HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
// HAL_PWR_EnableBkUpAccess(); // Enable access to backup SRAM
|
|
||||||
// __HAL_RCC_BKPSRAM_CLK_ENABLE();
|
|
||||||
// LL_PWR_EnableBkUpRegulator(); // Enable backup regulator
|
|
||||||
// while (!LL_PWR_IsActiveFlag_BRR()); // Wait until backup regulator is initialized
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HAL_timer_init();
|
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
|
|
||||||
USB_Hook_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
|
||||||
|
|
||||||
TERN_(HAS_SD_HOST_DRIVE, MSC_SD_init()); // Enable USB SD card access
|
|
||||||
|
|
||||||
#if PIN_EXISTS(USB_CONNECT)
|
|
||||||
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
|
||||||
delay_ms(1000); // Give OS time to notice
|
|
||||||
WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t MarlinHAL::get_reset_source() {
|
|
||||||
return watchdog_enable_caused_reboot() ? RST_WATCHDOG : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::reboot() { watchdog_reboot(0, 0, 1); }
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Watchdog Timer
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
#if ENABLED(USE_WATCHDOG)
|
|
||||||
|
|
||||||
#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "hardware/watchdog.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::watchdog_init() {
|
|
||||||
#if DISABLED(DISABLE_WATCHDOG_INIT)
|
|
||||||
static_assert(WDT_TIMEOUT_US > 1000, "WDT Timout is too small, aborting");
|
|
||||||
watchdog_enable(WDT_TIMEOUT_US/1000, true);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::watchdog_refresh() {
|
|
||||||
watchdog_update();
|
|
||||||
#if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED)
|
|
||||||
TOGGLE(LED_PIN); // heartbeat indicator
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// ADC
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
volatile bool MarlinHAL::adc_has_result = false;
|
|
||||||
|
|
||||||
void MarlinHAL::adc_init() {
|
|
||||||
analogReadResolution(HAL_ADC_RESOLUTION);
|
|
||||||
::adc_init();
|
|
||||||
adc_fifo_setup(true, false, 1, false, false);
|
|
||||||
irq_set_exclusive_handler(ADC_IRQ_FIFO, adc_exclusive_handler);
|
|
||||||
irq_set_enabled(ADC_IRQ_FIFO, true);
|
|
||||||
adc_irq_set_enabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::adc_enable(const pin_t pin) {
|
|
||||||
if (pin >= A0 && pin <= A3)
|
|
||||||
adc_gpio_init(pin);
|
|
||||||
else if (pin == HAL_ADC_MCU_TEMP_DUMMY_PIN)
|
|
||||||
adc_set_temp_sensor_enabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::adc_start(const pin_t pin) {
|
|
||||||
adc_has_result = false;
|
|
||||||
// Select an ADC input. 0...3 are GPIOs 26...29 respectively.
|
|
||||||
adc_select_input(pin == HAL_ADC_MCU_TEMP_DUMMY_PIN ? 4 : pin - A0);
|
|
||||||
adc_run(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::adc_exclusive_handler() {
|
|
||||||
adc_run(false); // Disable since we only want one result
|
|
||||||
irq_clear(ADC_IRQ_FIFO); // Clear the IRQ
|
|
||||||
|
|
||||||
if (adc_fifo_get_level() >= 1) {
|
|
||||||
adc_result = adc_fifo_get(); // Pop the result
|
|
||||||
adc_fifo_drain();
|
|
||||||
adc_has_result = true; // Signal the end of the conversion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t MarlinHAL::adc_value() { return adc_result; }
|
|
||||||
|
|
||||||
// Reset the system to initiate a firmware flash
|
|
||||||
void flashFirmware(const int16_t) { hal.reboot(); }
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void * _sbrk(int incr);
|
|
||||||
extern unsigned int __bss_end__; // end of bss section
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return free memory between end of heap (or end bss) and whatever is current
|
|
||||||
int freeMemory() {
|
|
||||||
int free_memory, heap_end = (int)_sbrk(0);
|
|
||||||
return (int)&free_memory - (heap_end ?: (int)&__bss_end__);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define CPU_32_BIT
|
|
||||||
|
|
||||||
#ifndef F_CPU
|
|
||||||
#define F_CPU (XOSC_MHZ * 1000000UL)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "arduino_extras.h"
|
|
||||||
#include "../../core/macros.h"
|
|
||||||
#include "../shared/Marduino.h"
|
|
||||||
#include "../shared/math_32bit.h"
|
|
||||||
#include "../shared/HAL_SPI.h"
|
|
||||||
#include "fastio.h"
|
|
||||||
//#include "Servo.h"
|
|
||||||
#include "watchdog.h"
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// Serial Ports
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Defines
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: review this to return 1 for pins that are not analog input
|
|
||||||
*/
|
|
||||||
#ifndef analogInputToDigitalPin
|
|
||||||
#define analogInputToDigitalPin(p) (p)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
|
||||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
|
||||||
#define cli() __disable_irq()
|
|
||||||
#define sei() __enable_irq()
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Types
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
template <bool, class L, class R> struct IFPIN { typedef R type; };
|
|
||||||
template <class L, class R> struct IFPIN<true, L, R> { typedef L type; };
|
|
||||||
typedef IFPIN<sizeof(pin_size_t) == 1, int8_t, int16_t>::type pin_t;
|
|
||||||
|
|
||||||
class libServo;
|
|
||||||
typedef libServo hal_servo_t;
|
|
||||||
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
|
|
||||||
#define RESUME_SERVO_OUTPUT() libServo::resume_all_servos()
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// ADC
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
#define HAL_ADC_VREF 3.3
|
|
||||||
#ifdef ADC_RESOLUTION
|
|
||||||
#define HAL_ADC_RESOLUTION ADC_RESOLUTION
|
|
||||||
#else
|
|
||||||
#define HAL_ADC_RESOLUTION 12
|
|
||||||
#endif
|
|
||||||
// ADC index 4 is the MCU temperature
|
|
||||||
#define HAL_ADC_MCU_TEMP_DUMMY_PIN 127
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pin Mapping for M42, M43, M226
|
|
||||||
//
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
|
||||||
|
|
||||||
#ifndef PLATFORM_M997_SUPPORT
|
|
||||||
#define PLATFORM_M997_SUPPORT
|
|
||||||
#endif
|
|
||||||
void flashFirmware(const int16_t);
|
|
||||||
|
|
||||||
// Maple Compatibility
|
|
||||||
typedef void (*systickCallback_t)(void);
|
|
||||||
void systick_attach_callback(systickCallback_t cb);
|
|
||||||
void HAL_SYSTICK_Callback();
|
|
||||||
|
|
||||||
extern volatile uint32_t systick_uptime_millis;
|
|
||||||
|
|
||||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
|
||||||
#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency()
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Class Utilities
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
int freeMemory();
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// MarlinHAL Class
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
class MarlinHAL {
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Earliest possible init, before setup()
|
|
||||||
MarlinHAL() {}
|
|
||||||
|
|
||||||
// Watchdog
|
|
||||||
static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {});
|
|
||||||
static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {});
|
|
||||||
|
|
||||||
static void init(); // Called early in setup()
|
|
||||||
static void init_board() {} // Called less early in setup()
|
|
||||||
static void reboot(); // Restart the firmware from 0x0
|
|
||||||
|
|
||||||
// Interrupts
|
|
||||||
static bool isr_state() { return !__get_PRIMASK(); }
|
|
||||||
static void isr_on() { __enable_irq(); }
|
|
||||||
static void isr_off() { __disable_irq(); }
|
|
||||||
|
|
||||||
static void delay_ms(const int ms) { ::delay(ms); }
|
|
||||||
|
|
||||||
// Tasks, called from idle()
|
|
||||||
static void idletask() {}
|
|
||||||
|
|
||||||
// Reset
|
|
||||||
static uint8_t get_reset_source();
|
|
||||||
static void clear_reset_source() {}
|
|
||||||
|
|
||||||
// Free SRAM
|
|
||||||
static int freeMemory() { return ::freeMemory(); }
|
|
||||||
|
|
||||||
//
|
|
||||||
// ADC Methods
|
|
||||||
//
|
|
||||||
|
|
||||||
// Called by Temperature::init once at startup
|
|
||||||
static void adc_init();
|
|
||||||
|
|
||||||
// Called by Temperature::init for each sensor at startup
|
|
||||||
static void adc_enable(const pin_t pin);
|
|
||||||
|
|
||||||
// Begin ADC sampling on the given pin. Called from Temperature::isr!
|
|
||||||
static void adc_start(const pin_t pin);
|
|
||||||
|
|
||||||
// This ADC runs a periodic task
|
|
||||||
static void adc_exclusive_handler();
|
|
||||||
|
|
||||||
// Is the ADC ready for reading?
|
|
||||||
static volatile bool adc_has_result;
|
|
||||||
static bool adc_ready() { return adc_has_result; }
|
|
||||||
|
|
||||||
// The current value of the ADC register
|
|
||||||
static uint16_t adc_value();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the PWM duty cycle for the pin to the given value.
|
|
||||||
* Optionally invert the duty cycle [default = false]
|
|
||||||
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
|
|
||||||
*/
|
|
||||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the frequency of the timer for the given pin as close as
|
|
||||||
* possible to the provided desired frequency. Internally calculate
|
|
||||||
* the required waveform generation mode, prescaler, and resolution
|
|
||||||
* values and set timer registers accordingly.
|
|
||||||
* NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B)
|
|
||||||
* NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST_PWM_FAN Settings)
|
|
||||||
*/
|
|
||||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
|
||||||
};
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
|
||||||
|
|
||||||
#include "../shared/HAL_MinSerial.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void TXBegin() {
|
|
||||||
#if !WITHIN(SERIAL_PORT, -1, 2)
|
|
||||||
#warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error."
|
|
||||||
#warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port."
|
|
||||||
#else
|
|
||||||
#if SERIAL_PORT == -1
|
|
||||||
USBSerial.begin(BAUDRATE);
|
|
||||||
#elif SERIAL_PORT == 0
|
|
||||||
USBSerial.begin(BAUDRATE);
|
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
Serial1.begin(BAUDRATE);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TX(char b){
|
|
||||||
#if SERIAL_PORT == -1
|
|
||||||
USBSerial
|
|
||||||
#elif SERIAL_PORT == 0
|
|
||||||
USBSerial
|
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
Serial1
|
|
||||||
#endif
|
|
||||||
.write(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
|
||||||
#define sw_barrier() __asm__ volatile("": : :"memory");
|
|
||||||
|
|
||||||
|
|
||||||
void install_min_serial() {
|
|
||||||
HAL_min_serial_init = &TXBegin;
|
|
||||||
HAL_min_serial_out = &TX;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // POSTMORTEM_DEBUGGING
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public Variables
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
static SPISettings spiConfig;
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public functions
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
#if ENABLED(SOFTWARE_SPI)
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Software SPI
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
#include "../shared/Delay.h"
|
|
||||||
|
|
||||||
void spiBegin(void) {
|
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
|
||||||
OUT_WRITE(SD_SCK_PIN, HIGH);
|
|
||||||
SET_INPUT(SD_MISO_PIN);
|
|
||||||
OUT_WRITE(SD_MOSI_PIN, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use function with compile-time value so we can actually reach the desired frequency
|
|
||||||
// Need to adjust this a little bit: on a 72MHz clock, we have 14ns/clock
|
|
||||||
// and we'll use ~3 cycles to jump to the method and going back, so it'll take ~40ns from the given clock here
|
|
||||||
#define CALLING_COST_NS (3U * 1000000000U) / (F_CPU)
|
|
||||||
void (*delaySPIFunc)();
|
|
||||||
void delaySPI_125() { DELAY_NS(125 - CALLING_COST_NS); }
|
|
||||||
void delaySPI_250() { DELAY_NS(250 - CALLING_COST_NS); }
|
|
||||||
void delaySPI_500() { DELAY_NS(500 - CALLING_COST_NS); }
|
|
||||||
void delaySPI_1000() { DELAY_NS(1000 - CALLING_COST_NS); }
|
|
||||||
void delaySPI_2000() { DELAY_NS(2000 - CALLING_COST_NS); }
|
|
||||||
void delaySPI_4000() { DELAY_NS(4000 - CALLING_COST_NS); }
|
|
||||||
|
|
||||||
void spiInit(uint8_t spiRate) {
|
|
||||||
// Use datarates Marlin uses
|
|
||||||
switch (spiRate) {
|
|
||||||
case SPI_FULL_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 8,000,000 actual: ~1.1M
|
|
||||||
case SPI_HALF_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 4,000,000 actual: ~1.1M
|
|
||||||
case SPI_QUARTER_SPEED:delaySPIFunc = &delaySPI_250; break; // desired: 2,000,000 actual: ~890K
|
|
||||||
case SPI_EIGHTH_SPEED: delaySPIFunc = &delaySPI_500; break; // desired: 1,000,000 actual: ~590K
|
|
||||||
case SPI_SPEED_5: delaySPIFunc = &delaySPI_1000; break; // desired: 500,000 actual: ~360K
|
|
||||||
case SPI_SPEED_6: delaySPIFunc = &delaySPI_2000; break; // desired: 250,000 actual: ~210K
|
|
||||||
default: delaySPIFunc = &delaySPI_4000; break; // desired: 125,000 actual: ~123K
|
|
||||||
}
|
|
||||||
SPI.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Begin SPI transaction, set clock, bit order, data mode
|
|
||||||
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ }
|
|
||||||
|
|
||||||
uint8_t HAL_SPI_RP2040_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
|
|
||||||
for (uint8_t bits = 8; bits--;) {
|
|
||||||
WRITE(SD_SCK_PIN, LOW);
|
|
||||||
WRITE(SD_MOSI_PIN, b & 0x80);
|
|
||||||
|
|
||||||
delaySPIFunc();
|
|
||||||
WRITE(SD_SCK_PIN, HIGH);
|
|
||||||
delaySPIFunc();
|
|
||||||
|
|
||||||
b <<= 1; // little setup time
|
|
||||||
b |= (READ(SD_MISO_PIN) != 0);
|
|
||||||
}
|
|
||||||
DELAY_NS(125);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Soft SPI receive byte
|
|
||||||
uint8_t spiRec() {
|
|
||||||
hal.isr_off(); // No interrupts during byte receive
|
|
||||||
const uint8_t data = HAL_SPI_RP2040_SpiTransfer_Mode_3(0xFF);
|
|
||||||
hal.isr_on(); // Enable interrupts
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Soft SPI read data
|
|
||||||
void spiRead(uint8_t *buf, uint16_t nbyte) {
|
|
||||||
for (uint16_t i = 0; i < nbyte; i++)
|
|
||||||
buf[i] = spiRec();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Soft SPI send byte
|
|
||||||
void spiSend(uint8_t data) {
|
|
||||||
hal.isr_off(); // No interrupts during byte send
|
|
||||||
HAL_SPI_RP2040_SpiTransfer_Mode_3(data); // Don't care what is received
|
|
||||||
hal.isr_on(); // Enable interrupts
|
|
||||||
}
|
|
||||||
|
|
||||||
// Soft SPI send block
|
|
||||||
void spiSendBlock(uint8_t token, const uint8_t *buf) {
|
|
||||||
spiSend(token);
|
|
||||||
for (uint16_t i = 0; i < 512; i++)
|
|
||||||
spiSend(buf[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Hardware SPI
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* VGPV SPI speed start and PCLK2/2, by default 108/2 = 54Mhz
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Begin SPI port setup
|
|
||||||
*
|
|
||||||
* @return Nothing
|
|
||||||
*
|
|
||||||
* @details Only configures SS pin since stm32duino creates and initialize the SPI object
|
|
||||||
*/
|
|
||||||
void spiBegin() {
|
|
||||||
#if PIN_EXISTS(SD_SS)
|
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure SPI for specified SPI speed
|
|
||||||
void spiInit(uint8_t spiRate) {
|
|
||||||
// Use datarates Marlin uses
|
|
||||||
uint32_t clock;
|
|
||||||
switch (spiRate) {
|
|
||||||
case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
|
|
||||||
case SPI_HALF_SPEED: clock = 5000000; break;
|
|
||||||
case SPI_QUARTER_SPEED: clock = 2500000; break;
|
|
||||||
case SPI_EIGHTH_SPEED: clock = 1250000; break;
|
|
||||||
case SPI_SPEED_5: clock = 625000; break;
|
|
||||||
case SPI_SPEED_6: clock = 300000; break;
|
|
||||||
default:
|
|
||||||
clock = 4000000; // Default from the SPI library
|
|
||||||
}
|
|
||||||
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
|
||||||
|
|
||||||
//SPI.setMISO(SD_MISO_PIN); //todo: implement? bad interface
|
|
||||||
//SPI.setMOSI(SD_MOSI_PIN);
|
|
||||||
//SPI.setSCLK(SD_SCK_PIN);
|
|
||||||
|
|
||||||
SPI.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Receives a single byte from the SPI port.
|
|
||||||
*
|
|
||||||
* @return Byte received
|
|
||||||
*
|
|
||||||
* @details
|
|
||||||
*/
|
|
||||||
uint8_t spiRec() {
|
|
||||||
uint8_t returnByte = SPI.transfer(0xFF);
|
|
||||||
return returnByte;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Receive a number of bytes from the SPI port to a buffer
|
|
||||||
*
|
|
||||||
* @param buf Pointer to starting address of buffer to write to.
|
|
||||||
* @param nbyte Number of bytes to receive.
|
|
||||||
* @return Nothing
|
|
||||||
*
|
|
||||||
* @details Uses DMA
|
|
||||||
*/
|
|
||||||
void spiRead(uint8_t *buf, uint16_t nbyte) {
|
|
||||||
if (nbyte == 0) return;
|
|
||||||
memset(buf, 0xFF, nbyte);
|
|
||||||
SPI.transfer(buf, nbyte);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Send a single byte on SPI port
|
|
||||||
*
|
|
||||||
* @param b Byte to send
|
|
||||||
*
|
|
||||||
* @details
|
|
||||||
*/
|
|
||||||
void spiSend(uint8_t b) {
|
|
||||||
SPI.transfer(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write token and then write from 512 byte buffer to SPI (for SD card)
|
|
||||||
*
|
|
||||||
* @param buf Pointer with buffer start address
|
|
||||||
* @return Nothing
|
|
||||||
*
|
|
||||||
* @details Use DMA
|
|
||||||
*/
|
|
||||||
void spiSendBlock(uint8_t token, const uint8_t *buf) {
|
|
||||||
//uint8_t rxBuf[512];
|
|
||||||
//SPI.transfer(token);
|
|
||||||
SPI.transfer((uint8_t*)buf, 512); //implement? bad interface
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SOFTWARE_SPI
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
#include "MarlinSerial.h"
|
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
#include "../../feature/e_parser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
|
||||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
|
||||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
|
||||||
IMPLEMENT_SERIAL(SERIAL_PORT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
#include "../../feature/e_parser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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)
|
|
||||||
|
|
||||||
#define SERIAL_INDEX_MIN 0
|
|
||||||
#define SERIAL_INDEX_MAX 6
|
|
||||||
#define USB_SERIAL_PORT(...) MSerial0
|
|
||||||
#include "../shared/serial_ports.h"
|
|
||||||
|
|
||||||
#if defined(LCD_SERIAL_PORT) && ANY(HAS_DGUS_LCD, EXTENSIBLE_UI)
|
|
||||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
|
||||||
#endif
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# RP2040 Hardware Interface
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#if HAS_SERVOS
|
|
||||||
|
|
||||||
#include "Servo.h"
|
|
||||||
|
|
||||||
static uint_fast8_t servoCount = 0;
|
|
||||||
static libServo *servos[NUM_SERVOS] = {0};
|
|
||||||
constexpr millis_t servoDelay[] = SERVO_DELAY;
|
|
||||||
static_assert(COUNT(servoDelay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
|
||||||
|
|
||||||
libServo::libServo()
|
|
||||||
: delay(servoDelay[servoCount]),
|
|
||||||
was_attached_before_pause(false),
|
|
||||||
value_before_pause(0)
|
|
||||||
{
|
|
||||||
servos[servoCount++] = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t libServo::attach(const int pin) {
|
|
||||||
if (servoCount >= MAX_SERVOS) return -1;
|
|
||||||
if (pin > 0) servo_pin = pin;
|
|
||||||
auto result = pico_servo.attach(servo_pin);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t libServo::attach(const int pin, const int min, const int max) {
|
|
||||||
if (servoCount >= MAX_SERVOS) return -1;
|
|
||||||
if (pin > 0) servo_pin = pin;
|
|
||||||
auto result = pico_servo.attach(servo_pin, min, max);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void libServo::move(const int value) {
|
|
||||||
if (attach(0) >= 0) {
|
|
||||||
pico_servo.write(value);
|
|
||||||
safe_delay(delay);
|
|
||||||
TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void libServo::pause() {
|
|
||||||
was_attached_before_pause = pico_servo.attached();
|
|
||||||
if (was_attached_before_pause) {
|
|
||||||
value_before_pause = pico_servo.read();
|
|
||||||
pico_servo.detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void libServo::resume() {
|
|
||||||
if (was_attached_before_pause) {
|
|
||||||
attach();
|
|
||||||
move(value_before_pause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void libServo::pause_all_servos() {
|
|
||||||
for (auto& servo : servos)
|
|
||||||
if (servo) servo->pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
void libServo::resume_all_servos() {
|
|
||||||
for (auto& servo : servos)
|
|
||||||
if (servo) servo->resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // HAS_SERVOS
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Servo.h>
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
#include "../../core/millis_t.h"
|
|
||||||
|
|
||||||
// Inherit and expand on the official library
|
|
||||||
class libServo {
|
|
||||||
public:
|
|
||||||
libServo();
|
|
||||||
int8_t attach(const int pin = 0); // pin == 0 uses value from previous call
|
|
||||||
int8_t attach(const int pin, const int min, const int max);
|
|
||||||
void detach() { pico_servo.detach(); }
|
|
||||||
int read() { return pico_servo.read(); }
|
|
||||||
void move(const int value);
|
|
||||||
|
|
||||||
void pause();
|
|
||||||
void resume();
|
|
||||||
|
|
||||||
static void pause_all_servos();
|
|
||||||
static void resume_all_servos();
|
|
||||||
static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Servo pico_servo;
|
|
||||||
|
|
||||||
int servo_pin = 0;
|
|
||||||
millis_t delay = 0;
|
|
||||||
|
|
||||||
bool was_attached_before_pause;
|
|
||||||
int value_before_pause;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
class libServo: public Servo {
|
|
||||||
public:
|
|
||||||
void move(const int value) {
|
|
||||||
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
|
||||||
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
|
||||||
|
|
||||||
if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach
|
|
||||||
write(value);
|
|
||||||
safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
|
|
||||||
TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class libServo;
|
|
||||||
typedef libServo hal_servo_t;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) {
|
|
||||||
char format_string[20];
|
|
||||||
snprintf(format_string, 20, "%%%d.%df", __width, __prec);
|
|
||||||
sprintf(__s, format_string, __val);
|
|
||||||
return __s;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// #include <stddef.h>
|
|
||||||
// #include <stdint.h>
|
|
||||||
// #include <math.h>
|
|
||||||
// #include <cstring>
|
|
||||||
|
|
||||||
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
|
|
||||||
Binary file not shown.
@@ -1,88 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#if ENABLED(FLASH_EEPROM_EMULATION)
|
|
||||||
|
|
||||||
#include "../shared/eeprom_api.h"
|
|
||||||
|
|
||||||
// NOTE: The Bigtreetech SKR Pico has an onboard W25Q16 flash module
|
|
||||||
|
|
||||||
// Use EEPROM.h for compatibility, for now.
|
|
||||||
#include <EEPROM.h>
|
|
||||||
|
|
||||||
static bool eeprom_data_written = false;
|
|
||||||
|
|
||||||
#ifndef MARLIN_EEPROM_SIZE
|
|
||||||
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
|
||||||
#endif
|
|
||||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
|
||||||
|
|
||||||
bool PersistentStore::access_start() {
|
|
||||||
EEPROM.begin(); // Avoid EEPROM.h warning (do nothing)
|
|
||||||
eeprom_buffer_fill();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PersistentStore::access_finish() {
|
|
||||||
if (eeprom_data_written) {
|
|
||||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
|
|
||||||
hal.isr_off();
|
|
||||||
eeprom_buffer_flush();
|
|
||||||
hal.isr_on();
|
|
||||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
|
|
||||||
eeprom_data_written = false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
|
||||||
while (size--) {
|
|
||||||
uint8_t v = *value;
|
|
||||||
if (v != eeprom_buffered_read_byte(pos)) {
|
|
||||||
eeprom_buffered_write_byte(pos, v);
|
|
||||||
eeprom_data_written = true;
|
|
||||||
}
|
|
||||||
crc16(crc, &v, 1);
|
|
||||||
pos++;
|
|
||||||
value++;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
|
||||||
do {
|
|
||||||
const uint8_t c = eeprom_buffered_read_byte(pos);
|
|
||||||
if (writing) *value = c;
|
|
||||||
crc16(crc, &c, 1);
|
|
||||||
pos++;
|
|
||||||
value++;
|
|
||||||
} while (--size);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FLASH_EEPROM_EMULATION
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#if USE_WIRED_EEPROM
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PersistentStore for Arduino-style EEPROM interface
|
|
||||||
* with simple implementations supplied by Marlin.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../shared/eeprom_if.h"
|
|
||||||
#include "../shared/eeprom_api.h"
|
|
||||||
|
|
||||||
#ifndef MARLIN_EEPROM_SIZE
|
|
||||||
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
|
||||||
#endif
|
|
||||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
|
||||||
|
|
||||||
bool PersistentStore::access_start() { eeprom_init(); return true; }
|
|
||||||
bool PersistentStore::access_finish() { return true; }
|
|
||||||
|
|
||||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
|
||||||
uint16_t written = 0;
|
|
||||||
while (size--) {
|
|
||||||
uint8_t v = *value;
|
|
||||||
uint8_t * const p = (uint8_t * const)pos;
|
|
||||||
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
|
|
||||||
eeprom_write_byte(p, v);
|
|
||||||
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
|
|
||||||
if (eeprom_read_byte(p) != v) {
|
|
||||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
crc16(crc, &v, 1);
|
|
||||||
pos++;
|
|
||||||
value++;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
|
||||||
do {
|
|
||||||
// Read from either external EEPROM, program flash or Backup SRAM
|
|
||||||
const uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
|
||||||
if (writing) *value = c;
|
|
||||||
crc16(crc, &c, 1);
|
|
||||||
pos++;
|
|
||||||
value++;
|
|
||||||
} while (--size);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_WIRED_EEPROM
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../../module/endstops.h"
|
|
||||||
|
|
||||||
// One ISR for all EXT-Interrupts
|
|
||||||
void endstop_ISR() { endstops.update(); }
|
|
||||||
|
|
||||||
void setup_endstop_interrupts() {
|
|
||||||
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
|
|
||||||
TERN_(USE_X_MAX, _ATTACH(X_MAX_PIN));
|
|
||||||
TERN_(USE_X_MIN, _ATTACH(X_MIN_PIN));
|
|
||||||
TERN_(USE_Y_MAX, _ATTACH(Y_MAX_PIN));
|
|
||||||
TERN_(USE_Y_MIN, _ATTACH(Y_MIN_PIN));
|
|
||||||
TERN_(USE_Z_MAX, _ATTACH(Z_MAX_PIN));
|
|
||||||
TERN_(HAS_Z_MIN_PIN, _ATTACH(Z_MIN_PIN));
|
|
||||||
TERN_(USE_X2_MAX, _ATTACH(X2_MAX_PIN));
|
|
||||||
TERN_(USE_X2_MIN, _ATTACH(X2_MIN_PIN));
|
|
||||||
TERN_(USE_Y2_MAX, _ATTACH(Y2_MAX_PIN));
|
|
||||||
TERN_(USE_Y2_MIN, _ATTACH(Y2_MIN_PIN));
|
|
||||||
TERN_(USE_Z2_MAX, _ATTACH(Z2_MAX_PIN));
|
|
||||||
TERN_(USE_Z2_MIN, _ATTACH(Z2_MIN_PIN));
|
|
||||||
TERN_(USE_Z3_MAX, _ATTACH(Z3_MAX_PIN));
|
|
||||||
TERN_(USE_Z3_MIN, _ATTACH(Z3_MIN_PIN));
|
|
||||||
TERN_(USE_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
|
||||||
TERN_(USE_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
|
||||||
TERN_(USE_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
|
||||||
TERN_(USE_I_MAX, _ATTACH(I_MAX_PIN));
|
|
||||||
TERN_(USE_I_MIN, _ATTACH(I_MIN_PIN));
|
|
||||||
TERN_(USE_J_MAX, _ATTACH(J_MAX_PIN));
|
|
||||||
TERN_(USE_J_MIN, _ATTACH(J_MIN_PIN));
|
|
||||||
TERN_(USE_K_MAX, _ATTACH(K_MAX_PIN));
|
|
||||||
TERN_(USE_K_MIN, _ATTACH(K_MIN_PIN));
|
|
||||||
TERN_(USE_U_MAX, _ATTACH(U_MAX_PIN));
|
|
||||||
TERN_(USE_U_MIN, _ATTACH(U_MIN_PIN));
|
|
||||||
TERN_(USE_V_MAX, _ATTACH(V_MAX_PIN));
|
|
||||||
TERN_(USE_V_MIN, _ATTACH(V_MIN_PIN));
|
|
||||||
TERN_(USE_W_MAX, _ATTACH(W_MAX_PIN));
|
|
||||||
TERN_(USE_W_MIN, _ATTACH(W_MIN_PIN));
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#include "HAL.h"
|
|
||||||
#include "pinDefinitions.h"
|
|
||||||
|
|
||||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
|
||||||
analogWrite(pin, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
|
||||||
mbed::PwmOut* pwm = digitalPinToPwm(pin);
|
|
||||||
if (pwm != NULL) delete pwm;
|
|
||||||
pwm = new mbed::PwmOut(digitalPinToPinName(pin));
|
|
||||||
digitalPinToPwm(pin) = pwm;
|
|
||||||
pwm->period_ms(1000 / f_desired);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
void FastIO_init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fast I/O interfaces for RP2040
|
|
||||||
* These use GPIO register access for fast port manipulation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public Variables
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public functions
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
void FastIO_init(); // Must be called before using fast io macros
|
|
||||||
#define FASTIO_INIT() FastIO_init()
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Defines
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
#define _BV32(b) (1UL << (b))
|
|
||||||
|
|
||||||
#ifndef PWM
|
|
||||||
#define PWM OUTPUT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _WRITE(IO, V) digitalWrite((IO), (V))
|
|
||||||
|
|
||||||
#define _READ(IO) digitalRead(IO)
|
|
||||||
#define _TOGGLE(IO) digitalWrite(IO, !digitalRead(IO))
|
|
||||||
|
|
||||||
#define _GET_MODE(IO)
|
|
||||||
#define _SET_MODE(IO,M) pinMode(IO, M)
|
|
||||||
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL
|
|
||||||
#define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN)
|
|
||||||
|
|
||||||
#define WRITE(IO,V) _WRITE(IO,V)
|
|
||||||
#define READ(IO) _READ(IO)
|
|
||||||
#define TOGGLE(IO) _TOGGLE(IO)
|
|
||||||
|
|
||||||
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
|
||||||
#define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
|
|
||||||
|
|
||||||
#define SET_INPUT(IO) _SET_MODE(IO, INPUT) //!< Input Floating Mode
|
|
||||||
#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_PWM(IO) _SET_MODE(IO, PWM)
|
|
||||||
|
|
||||||
#define IS_INPUT(IO)
|
|
||||||
#define IS_OUTPUT(IO)
|
|
||||||
|
|
||||||
#define PWM_PIN(P) true //digitalPinHasPWM(P)
|
|
||||||
#define NO_COMPILE_TIME_PWM
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
|
||||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
|
||||||
|
|
||||||
#undef I2C_SDA
|
|
||||||
#define I2C_SDA_PIN PIN_WIRE_SDA
|
|
||||||
#undef I2C_SCL
|
|
||||||
#define I2C_SCL_PIN PIN_WIRE_SCL
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if ALL(SDSUPPORT, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
|
|
||||||
#define HAS_SD_HOST_DRIVE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fix F_CPU not being a compile-time constant in RP2040 framework
|
|
||||||
#ifdef BOARD_F_CPU
|
|
||||||
#undef F_CPU
|
|
||||||
#define F_CPU BOARD_F_CPU
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The Sensitive Pins array is not optimizable
|
|
||||||
#define RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// If no real or emulated EEPROM selected, fall back to SD emulation
|
|
||||||
#if USE_FALLBACK_EEPROM
|
|
||||||
#define SDCARD_EEPROM_EMULATION
|
|
||||||
#elif ANY(I2C_EEPROM, SPI_EEPROM)
|
|
||||||
#define USE_SHARED_EEPROM 1
|
|
||||||
#endif
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test RP2040-specific configuration values for errors at compile-time.
|
|
||||||
*/
|
|
||||||
//#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
|
|
||||||
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#if ENABLED(SDCARD_EEPROM_EMULATION) && !HAS_MEDIA
|
|
||||||
#undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
|
|
||||||
#if USE_FALLBACK_EEPROM
|
|
||||||
#warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
|
|
||||||
#endif
|
|
||||||
#error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(SRAM_EEPROM_EMULATION)
|
|
||||||
#error "SRAM_EEPROM_EMULATION is not supported for RP2040."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ALL(PRINTCOUNTER, FLASH_EEPROM_EMULATION)
|
|
||||||
#warning "FLASH_EEPROM_EMULATION may cause long delays when writing and should not be used while printing."
|
|
||||||
#error "Disable PRINTCOUNTER or choose another EEPROM emulation."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(FLASH_EEPROM_LEVELING)
|
|
||||||
#error "FLASH_EEPROM_LEVELING is not supported for RP2040."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
|
|
||||||
#error "SERIAL_STATS_MAX_RX_QUEUED is not supported on RP2040."
|
|
||||||
#elif ENABLED(SERIAL_STATS_DROPPED_RX)
|
|
||||||
#error "SERIAL_STATS_DROPPED_RX is not supported on RP2040."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI)
|
|
||||||
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are not supported for RP2040."
|
|
||||||
#endif
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#if HAS_SD_HOST_DRIVE
|
|
||||||
|
|
||||||
#include "../shared/Marduino.h"
|
|
||||||
#include "msc_sd.h"
|
|
||||||
#include "usbd_core.h"
|
|
||||||
|
|
||||||
#include "../../sd/cardreader.h"
|
|
||||||
|
|
||||||
#include <USB.h>
|
|
||||||
#include <USBMscHandler.h>
|
|
||||||
|
|
||||||
#define BLOCK_SIZE 512
|
|
||||||
#define PRODUCT_ID 0x29
|
|
||||||
|
|
||||||
class Sd2CardUSBMscHandler : public USBMscHandler {
|
|
||||||
public:
|
|
||||||
DiskIODriver* diskIODriver() {
|
|
||||||
#if HAS_MULTI_VOLUME
|
|
||||||
#if SHARED_VOLUME_IS(SD_ONBOARD)
|
|
||||||
return &card.media_driver_sdcard;
|
|
||||||
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
|
|
||||||
return &card.media_driver_usbFlash;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
return card.diskIODriver();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) {
|
|
||||||
*pBlockNum = diskIODriver()->cardSize();
|
|
||||||
*pBlockSize = BLOCK_SIZE;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
|
|
||||||
auto sd2card = diskIODriver();
|
|
||||||
// single block
|
|
||||||
if (blkLen == 1) {
|
|
||||||
watchdog_refresh();
|
|
||||||
sd2card->writeBlock(blkAddr, pBuf);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// multi block optimization
|
|
||||||
sd2card->writeStart(blkAddr, blkLen);
|
|
||||||
while (blkLen--) {
|
|
||||||
watchdog_refresh();
|
|
||||||
sd2card->writeData(pBuf);
|
|
||||||
pBuf += BLOCK_SIZE;
|
|
||||||
}
|
|
||||||
sd2card->writeStop();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
|
|
||||||
auto sd2card = diskIODriver();
|
|
||||||
// single block
|
|
||||||
if (blkLen == 1) {
|
|
||||||
watchdog_refresh();
|
|
||||||
sd2card->readBlock(blkAddr, pBuf);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// multi block optimization
|
|
||||||
sd2card->readStart(blkAddr);
|
|
||||||
while (blkLen--) {
|
|
||||||
watchdog_refresh();
|
|
||||||
sd2card->readData(pBuf);
|
|
||||||
pBuf += BLOCK_SIZE;
|
|
||||||
}
|
|
||||||
sd2card->readStop();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsReady() {
|
|
||||||
return diskIODriver()->isReady();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Sd2CardUSBMscHandler usbMscHandler;
|
|
||||||
|
|
||||||
/* USB Mass storage Standard Inquiry Data */
|
|
||||||
uint8_t Marlin_STORAGE_Inquirydata[] = { /* 36 */
|
|
||||||
/* LUN 0 */
|
|
||||||
0x00,
|
|
||||||
0x80,
|
|
||||||
0x02,
|
|
||||||
0x02,
|
|
||||||
(STANDARD_INQUIRY_DATA_LEN - 5),
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
'M', 'A', 'R', 'L', 'I', 'N', ' ', ' ', /* Manufacturer : 8 bytes */
|
|
||||||
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
|
|
||||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
||||||
'0', '.', '0', '1', /* Version : 4 Bytes */
|
|
||||||
};
|
|
||||||
|
|
||||||
USBMscHandler *pSingleMscHandler = &usbMscHandler;
|
|
||||||
|
|
||||||
void MSC_SD_init() {
|
|
||||||
USBDevice.end();
|
|
||||||
delay(200);
|
|
||||||
USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata);
|
|
||||||
USBDevice.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // HAS_SD_HOST_DRIVE
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
void MSC_SD_init();
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "HAL.h"
|
|
||||||
|
|
||||||
#ifndef NUM_DIGITAL_PINS
|
|
||||||
#error "Expected NUM_DIGITAL_PINS not found"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Life gets complicated if you want an easy to use 'M43 I' output (in port/pin order)
|
|
||||||
* because the variants in this platform do not always define all the I/O port/pins
|
|
||||||
* that a CPU has.
|
|
||||||
*
|
|
||||||
* VARIABLES:
|
|
||||||
* Ard_num - Arduino pin number - defined by the platform. It is used by digitalRead and
|
|
||||||
* digitalWrite commands and by M42.
|
|
||||||
* - does not contain port/pin info
|
|
||||||
* - is not in port/pin order
|
|
||||||
* - typically a variant will only assign Ard_num to port/pins that are actually used
|
|
||||||
* Index - M43 counter - only used to get Ard_num
|
|
||||||
* x - a parameter/argument used to search the pin_array to try to find a signal name
|
|
||||||
* associated with a Ard_num
|
|
||||||
* Port_pin - port number and pin number for use with CPU registers and printing reports
|
|
||||||
*
|
|
||||||
* Since M43 uses digitalRead and digitalWrite commands, only the Port_pins with an Ard_num
|
|
||||||
* are accessed and/or displayed.
|
|
||||||
*
|
|
||||||
* Three arrays are used.
|
|
||||||
*
|
|
||||||
* digitalPin[] is provided by the platform. It consists of the Port_pin numbers in
|
|
||||||
* Arduino pin number order.
|
|
||||||
*
|
|
||||||
* pin_array is a structure generated by the pins/pinsDebug.h header file. It is generated by
|
|
||||||
* the preprocessor. Only the signals associated with enabled options are in this table.
|
|
||||||
* It contains:
|
|
||||||
* - name of the signal
|
|
||||||
* - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines.
|
|
||||||
* EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as the
|
|
||||||
* argument to digitalPinToPinName(IO) to get the Port_pin number
|
|
||||||
* - if it is a digital or analog signal. PWMs are considered digital here.
|
|
||||||
*
|
|
||||||
* pin_xref is a structure generated by this header file. It is generated by the
|
|
||||||
* preprocessor. It is in port/pin order. It contains just the port/pin numbers defined by the
|
|
||||||
* platform for this variant.
|
|
||||||
* - Ard_num
|
|
||||||
* - printable version of Port_pin
|
|
||||||
*
|
|
||||||
* Routines with an "x" as a parameter/argument are used to search the pin_array to try to
|
|
||||||
* find a signal name associated with a port/pin.
|
|
||||||
*
|
|
||||||
* NOTE - the Arduino pin number is what is used by the M42 command, NOT the port/pin for that
|
|
||||||
* signal. The Arduino pin number is listed by the M43 I command.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NUM_ANALOG_FIRST A0
|
|
||||||
|
|
||||||
#define MODE_PIN_INPUT 0 // Input mode (reset state)
|
|
||||||
#define MODE_PIN_OUTPUT 1 // General purpose output mode
|
|
||||||
#define MODE_PIN_ALT 2 // Alternate function mode
|
|
||||||
#define MODE_PIN_ANALOG 3 // Analog mode
|
|
||||||
|
|
||||||
#define PIN_NUM(P) (P & 0x000F)
|
|
||||||
#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1')
|
|
||||||
#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 )
|
|
||||||
#define PORT_NUM(P) ((P >> 4) & 0x0007)
|
|
||||||
#define PORT_ALPHA(P) ('A' + (P >> 4))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translation of routines & variables used by pinsDebug.h
|
|
||||||
*/
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
|
||||||
#define VALID_PIN(ANUM) (pin_t(ANUM) >= 0 && pin_t(ANUM) < NUMBER_PINS_TOTAL)
|
|
||||||
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
|
|
||||||
#define PRINT_PIN(Q)
|
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine
|
|
||||||
|
|
||||||
// x is a variable used to search pin_array
|
|
||||||
#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
|
|
||||||
#define GET_ARRAY_PIN(x) ((pin_t) pin_array[x].pin)
|
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
|
||||||
#define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin
|
|
||||||
|
|
||||||
uint8_t get_pin_mode(const pin_t Ard_num) {
|
|
||||||
|
|
||||||
uint dir = gpio_get_dir( Ard_num);
|
|
||||||
|
|
||||||
if(dir) return MODE_PIN_OUTPUT;
|
|
||||||
else return MODE_PIN_INPUT;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t digital_pin_to_analog_pin(pin_t Ard_num) {
|
|
||||||
Ard_num -= NUM_ANALOG_FIRST;
|
|
||||||
return (Ard_num >= 0 && Ard_num < NUM_ANALOG_INPUTS) ? Ard_num : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isAnalogPin(const pin_t Ard_num) {
|
|
||||||
return digital_pin_to_analog_pin(Ard_num) != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_digital(const pin_t x) {
|
|
||||||
const uint8_t pin_mode = get_pin_mode(x);
|
|
||||||
return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printPinPort(const pin_t Ard_num) {
|
|
||||||
SERIAL_ECHOPGM("Pin: ");
|
|
||||||
SERIAL_ECHO(Ard_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pwm_status(const pin_t Ard_num) {
|
|
||||||
return get_pin_mode(Ard_num) == MODE_PIN_ALT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printPinPWM(const pin_t Ard_num) {
|
|
||||||
if (PWM_PIN(Ard_num)) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define SPI Pins: SCK, MISO, MOSI, SS
|
|
||||||
*/
|
|
||||||
#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
|
|
||||||
#ifndef SD_SS_PIN
|
|
||||||
#define SD_SS_PIN PIN_SPI_SS
|
|
||||||
#endif
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "../platforms.h"
|
|
||||||
|
|
||||||
#ifdef __PLAT_RP2040__
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
alarm_pool_t* HAL_timer_pool_0;
|
|
||||||
alarm_pool_t* HAL_timer_pool_1;
|
|
||||||
alarm_pool_t* HAL_timer_pool_2;
|
|
||||||
alarm_pool_t* HAL_timer_pool_3;
|
|
||||||
|
|
||||||
struct repeating_timer HAL_timer_0;
|
|
||||||
struct repeating_timer HAL_timer_1;
|
|
||||||
struct repeating_timer HAL_timer_2;
|
|
||||||
struct repeating_timer HAL_timer_3;
|
|
||||||
|
|
||||||
volatile bool HAL_timer_irq_en[4] = { false, false, false, false };
|
|
||||||
|
|
||||||
void HAL_timer_init() {
|
|
||||||
//reserve all the available alarm pools to use as "pseudo" hardware timers
|
|
||||||
//HAL_timer_pool_0 = alarm_pool_create(0,2);
|
|
||||||
HAL_timer_pool_1 = alarm_pool_create(1, 6);
|
|
||||||
HAL_timer_pool_0 = HAL_timer_pool_1;
|
|
||||||
HAL_timer_pool_2 = alarm_pool_create(2, 6);
|
|
||||||
HAL_timer_pool_3 = HAL_timer_pool_2;
|
|
||||||
//HAL_timer_pool_3 = alarm_pool_create(3, 6);
|
|
||||||
|
|
||||||
irq_set_priority(TIMER_IRQ_0, 0xC0);
|
|
||||||
irq_set_priority(TIMER_IRQ_1, 0x80);
|
|
||||||
irq_set_priority(TIMER_IRQ_2, 0x40);
|
|
||||||
irq_set_priority(TIMER_IRQ_3, 0x00);
|
|
||||||
|
|
||||||
//alarm_pool_init_default();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
|
||||||
const int64_t freq = (int64_t)frequency,
|
|
||||||
us = (1000000ll / freq) * -1ll;
|
|
||||||
bool result;
|
|
||||||
switch (timer_num) {
|
|
||||||
case 0:
|
|
||||||
result = alarm_pool_add_repeating_timer_us(HAL_timer_pool_0, us, HAL_timer_repeating_0_callback, NULL, &HAL_timer_0);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
result = alarm_pool_add_repeating_timer_us(HAL_timer_pool_1, us, HAL_timer_repeating_1_callback, NULL, &HAL_timer_1);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
result = alarm_pool_add_repeating_timer_us(HAL_timer_pool_2, us, HAL_timer_repeating_2_callback, NULL, &HAL_timer_2);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
result = alarm_pool_add_repeating_timer_us(HAL_timer_pool_3, us, HAL_timer_repeating_3_callback, NULL, &HAL_timer_3);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
UNUSED(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_timer_stop(const uint8_t timer_num) {
|
|
||||||
switch (timer_num) {
|
|
||||||
case 0: cancel_repeating_timer(&HAL_timer_0); break;
|
|
||||||
case 1: cancel_repeating_timer(&HAL_timer_1); break;
|
|
||||||
case 2: cancel_repeating_timer(&HAL_timer_2); break;
|
|
||||||
case 3: cancel_repeating_timer(&HAL_timer_3); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t HAL_timer_alarm_pool_0_callback(long int, void*) {
|
|
||||||
if (HAL_timer_irq_en[0]) HAL_timer_0_callback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int64_t HAL_timer_alarm_pool_1_callback(long int, void*) {
|
|
||||||
if (HAL_timer_irq_en[1]) HAL_timer_1_callback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int64_t HAL_timer_alarm_pool_2_callback(long int, void*) {
|
|
||||||
if (HAL_timer_irq_en[2]) HAL_timer_2_callback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int64_t HAL_timer_alarm_pool_3_callback(long int, void*) {
|
|
||||||
if (HAL_timer_irq_en[3]) HAL_timer_3_callback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HAL_timer_repeating_0_callback(repeating_timer* timer) {
|
|
||||||
if (HAL_timer_irq_en[0]) HAL_timer_0_callback();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool HAL_timer_repeating_1_callback(repeating_timer* timer) {
|
|
||||||
if (HAL_timer_irq_en[1]) HAL_timer_1_callback();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool HAL_timer_repeating_2_callback(repeating_timer* timer) {
|
|
||||||
if (HAL_timer_irq_en[2]) HAL_timer_2_callback();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool HAL_timer_repeating_3_callback(repeating_timer* timer) {
|
|
||||||
if (HAL_timer_irq_en[3]) HAL_timer_3_callback();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __attribute__((weak)) HAL_timer_0_callback() {}
|
|
||||||
void __attribute__((weak)) HAL_timer_1_callback() {}
|
|
||||||
void __attribute__((weak)) HAL_timer_2_callback() {}
|
|
||||||
void __attribute__((weak)) HAL_timer_3_callback() {}
|
|
||||||
|
|
||||||
#endif // __PLAT_RP2040__
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
||||||
*
|
|
||||||
* Based on Sprinter and grbl.
|
|
||||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "../../core/macros.h"
|
|
||||||
|
|
||||||
#ifdef PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
|
|
||||||
#undef PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
|
|
||||||
#define PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 0
|
|
||||||
#else
|
|
||||||
#define PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Defines
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
//#define _HAL_TIMER(T) _CAT(LPC_TIM, T)
|
|
||||||
//#define _HAL_TIMER_IRQ(T) TIMER##T##_IRQn
|
|
||||||
//#define __HAL_TIMER_ISR(T) extern "C" alarm_callback_t HAL_timer_alarm_pool_##T##_callback()
|
|
||||||
#define __HAL_TIMER_ISR(T) extern void HAL_timer_##T##_callback()
|
|
||||||
#define _HAL_TIMER_ISR(T) __HAL_TIMER_ISR(T)
|
|
||||||
|
|
||||||
typedef uint64_t hal_timer_t;
|
|
||||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFFFFFFFFFF
|
|
||||||
|
|
||||||
#define HAL_TIMER_RATE (1000000ull) // fixed value as we use a microsecond timesource
|
|
||||||
#ifndef MF_TIMER_STEP
|
|
||||||
#define MF_TIMER_STEP 0 // Timer Index for Stepper
|
|
||||||
#endif
|
|
||||||
#ifndef MF_TIMER_PULSE
|
|
||||||
#define MF_TIMER_PULSE MF_TIMER_STEP
|
|
||||||
#endif
|
|
||||||
#ifndef MF_TIMER_TEMP
|
|
||||||
#define MF_TIMER_TEMP 1 // Timer Index for Temperature
|
|
||||||
#endif
|
|
||||||
#ifndef MF_TIMER_PWM
|
|
||||||
#define MF_TIMER_PWM 3 // Timer Index for PWM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEMP_TIMER_RATE HAL_TIMER_RATE
|
|
||||||
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
|
|
||||||
|
|
||||||
#define STEPPER_TIMER_RATE HAL_TIMER_RATE / 10 // 100khz roughly
|
|
||||||
#define STEPPER_TIMER_TICKS_PER_US (0.1) // fixed value as we use a microsecond timesource
|
|
||||||
#define STEPPER_TIMER_PRESCALE (10)
|
|
||||||
|
|
||||||
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
|
|
||||||
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
|
||||||
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
|
|
||||||
|
|
||||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP)
|
|
||||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP)
|
|
||||||
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP)
|
|
||||||
|
|
||||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP)
|
|
||||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP)
|
|
||||||
|
|
||||||
#ifndef HAL_STEP_TIMER_ISR
|
|
||||||
#define HAL_STEP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_STEP)
|
|
||||||
#endif
|
|
||||||
#ifndef HAL_TEMP_TIMER_ISR
|
|
||||||
#define HAL_TEMP_TIMER_ISR() _HAL_TIMER_ISR(MF_TIMER_TEMP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Timer references by index
|
|
||||||
//#define STEP_TIMER_PTR _HAL_TIMER(MF_TIMER_STEP)
|
|
||||||
//#define TEMP_TIMER_PTR _HAL_TIMER(MF_TIMER_TEMP)
|
|
||||||
|
|
||||||
extern alarm_pool_t* HAL_timer_pool_0;
|
|
||||||
extern alarm_pool_t* HAL_timer_pool_1;
|
|
||||||
extern alarm_pool_t* HAL_timer_pool_2;
|
|
||||||
extern alarm_pool_t* HAL_timer_pool_3;
|
|
||||||
|
|
||||||
extern struct repeating_timer HAL_timer_0;
|
|
||||||
|
|
||||||
void HAL_timer_0_callback();
|
|
||||||
void HAL_timer_1_callback();
|
|
||||||
void HAL_timer_2_callback();
|
|
||||||
void HAL_timer_3_callback();
|
|
||||||
|
|
||||||
int64_t HAL_timer_alarm_pool_0_callback(long int, void*);
|
|
||||||
int64_t HAL_timer_alarm_pool_1_callback(long int, void*);
|
|
||||||
int64_t HAL_timer_alarm_pool_2_callback(long int, void*);
|
|
||||||
int64_t HAL_timer_alarm_pool_3_callback(long int, void*);
|
|
||||||
|
|
||||||
bool HAL_timer_repeating_0_callback(repeating_timer* timer);
|
|
||||||
bool HAL_timer_repeating_1_callback(repeating_timer* timer);
|
|
||||||
bool HAL_timer_repeating_2_callback(repeating_timer* timer);
|
|
||||||
bool HAL_timer_repeating_3_callback(repeating_timer* timer);
|
|
||||||
|
|
||||||
extern volatile bool HAL_timer_irq_en[4];
|
|
||||||
|
|
||||||
// ------------------------
|
|
||||||
// Public functions
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
void HAL_timer_init();
|
|
||||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
|
||||||
void HAL_timer_stop(const uint8_t timer_num);
|
|
||||||
|
|
||||||
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t compare) {
|
|
||||||
|
|
||||||
if (timer_num == MF_TIMER_STEP){
|
|
||||||
if (compare == HAL_TIMER_TYPE_MAX){
|
|
||||||
HAL_timer_stop(timer_num);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compare = compare *10; //Dirty fix, figure out a proper way
|
|
||||||
|
|
||||||
switch (timer_num) {
|
|
||||||
case 0:
|
|
||||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_0 ,compare , HAL_timer_alarm_pool_0_callback ,0 ,false );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_1 ,compare , HAL_timer_alarm_pool_1_callback ,0 ,false );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_2 ,compare , HAL_timer_alarm_pool_2_callback ,0 ,false );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
alarm_pool_add_alarm_in_us(HAL_timer_pool_3 ,compare , HAL_timer_alarm_pool_3_callback ,0 ,false );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
|
||||||
if (timer_num == MF_TIMER_STEP) return 0ull;
|
|
||||||
return time_us_64();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FORCE_INLINE static void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
|
||||||
HAL_timer_irq_en[timer_num] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
|
||||||
HAL_timer_irq_en[timer_num] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
|
||||||
return HAL_timer_irq_en[timer_num]; //lucky coincidence that timer_num and rp2040 irq num matches
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define HAL_timer_isr_epilogue(T) NOOP
|
|
||||||
@@ -107,7 +107,7 @@ void MarlinHAL::init() {
|
|||||||
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,11 @@
|
|||||||
// ------------------------
|
// ------------------------
|
||||||
// Serial ports
|
// Serial ports
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
#include "../../core/serial_hook.h"
|
#include "../../core/serial_hook.h"
|
||||||
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||||
extern DefaultSerial1 MSerialUSB;
|
extern DefaultSerial1 MSerialUSB;
|
||||||
|
|
||||||
|
// Serial ports
|
||||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||||
|
|
||||||
@@ -51,10 +51,43 @@ extern DefaultSerial3 MSerial1;
|
|||||||
#define _MSERIAL(X) __MSERIAL(X)
|
#define _MSERIAL(X) __MSERIAL(X)
|
||||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||||
|
|
||||||
#define SERIAL_INDEX_MIN 0
|
#if WITHIN(SERIAL_PORT, 0, 1)
|
||||||
#define SERIAL_INDEX_MAX 1
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||||
#define USB_SERIAL_PORT(...) MSerialUSB
|
#elif SERIAL_PORT == -1
|
||||||
#include "../shared/serial_ports.h"
|
#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
|
||||||
|
|
||||||
typedef int8_t pin_t;
|
typedef int8_t pin_t;
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
SPI.beginTransaction(spiConfig);
|
SPI.beginTransaction(spiConfig);
|
||||||
SPI.transfer(buf, nbyte);
|
SPI.transfer(buf, nbyte);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,57 +22,41 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for SAMD21
|
* SAMD21 HAL developed by Bart Meijer (brupje)
|
||||||
*
|
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL PINS_COUNT
|
#define NUMBER_PINS_TOTAL PINS_COUNT
|
||||||
|
|
||||||
#define digitalRead_mod(P) extDigitalRead(P)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
|
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0)
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
|
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital
|
||||||
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
|
#define isValidPin(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL)
|
||||||
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) != -1)
|
#define isAnalogPin(P) (digitalPinToAnalogIndex(P)!=-1)
|
||||||
#define pwm_status(P) digitalPinHasPWM(P)
|
#define pwm_status(pin) digitalPinHasPWM(pin)
|
||||||
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||||
// uses pin index
|
// uses pin index
|
||||||
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
|
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
|
||||||
|
|
||||||
bool getValidPinMode(const int8_t pin) { // 1: output, 0: input
|
bool getValidPinMode(int8_t pin) { // 1: output, 0: input
|
||||||
const EPortType samdport = g_APinDescription[pin].ulPort;
|
const EPortType samdport = g_APinDescription[pin].ulPort;
|
||||||
const uint32_t samdpin = g_APinDescription[pin].ulPin;
|
const uint32_t samdpin = g_APinDescription[pin].ulPin;
|
||||||
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
|
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPWM(const int32_t pin) {
|
void printPinPWM(int32_t pin) {
|
||||||
if (pwm_status(pin)) {
|
if (pwm_status(pin)) {
|
||||||
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
||||||
//SERIAL_ECHOPGM("PWM = ", duty);
|
//SERIAL_ECHOPGM("PWM = ", duty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPort(const pin_t) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SAMD21 Board pin| PORT | Label
|
* SAMD21 Board pin| PORT | Label
|
||||||
* ----------------+--------+-------
|
* ----------------+--------+-------
|
||||||
|
|||||||
@@ -45,3 +45,10 @@
|
|||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN 37
|
#define SD_MOSI_PIN 37
|
||||||
#endif
|
#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)
|
#if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,72 @@
|
|||||||
|
|
||||||
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
|
||||||
#include "MarlinSerial_AGCM4.h"
|
#include "MarlinSerial_AGCM4.h"
|
||||||
#endif
|
|
||||||
|
// 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
|
||||||
|
|
||||||
typedef int8_t pin_t;
|
typedef int8_t pin_t;
|
||||||
|
|
||||||
|
|||||||
@@ -32,24 +32,3 @@ typedef Serial1Class<Uart> UartT;
|
|||||||
extern UartT Serial2;
|
extern UartT Serial2;
|
||||||
extern UartT Serial3;
|
extern UartT Serial3;
|
||||||
extern UartT Serial4;
|
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"
|
|
||||||
|
|||||||
@@ -22,57 +22,40 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pins Debugging for SAMD51
|
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
|
||||||
*
|
|
||||||
* - NUMBER_PINS_TOTAL
|
|
||||||
* - MULTI_NAME_PAD
|
|
||||||
* - getPinByIndex(index)
|
|
||||||
* - printPinNameByIndex(index)
|
|
||||||
* - getPinIsDigitalByIndex(index)
|
|
||||||
* - digitalPinToAnalogIndex(pin)
|
|
||||||
* - getValidPinMode(pin)
|
|
||||||
* - isValidPin(pin)
|
|
||||||
* - isAnalogPin(pin)
|
|
||||||
* - digitalRead_mod(pin)
|
|
||||||
* - pwm_status(pin)
|
|
||||||
* - printPinPWM(pin)
|
|
||||||
* - printPinPort(pin)
|
|
||||||
* - printPinNumber(pin)
|
|
||||||
* - printPinAnalog(pin)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL PINS_COUNT
|
#define NUMBER_PINS_TOTAL PINS_COUNT
|
||||||
|
|
||||||
#define digitalRead_mod(P) extDigitalRead(P)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
|
#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0)
|
||||||
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0)
|
#define printPinNumber(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0)
|
#define printPinAnalog(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define getPinByIndex(x) pin_array[x].pin
|
#define getPinByIndex(p) pin_array[p].pin
|
||||||
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
|
#define getPinIsDigitalByIndex(p) pin_array[p].is_digital
|
||||||
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
|
#define isValidPin(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
|
||||||
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) != -1)
|
#define isAnalogPin(P) (digitalPinToAnalogIndex(P)!=-1)
|
||||||
#define pwm_status(P) digitalPinHasPWM(P)
|
#define pwm_status(pin) digitalPinHasPWM(pin)
|
||||||
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
|
||||||
// uses pin index
|
// uses pin index
|
||||||
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
|
#define M43_NEVER_TOUCH(Q) ((Q) >= 75)
|
||||||
|
|
||||||
bool getValidPinMode(const int8_t pin) { // 1: output, 0: input
|
bool getValidPinMode(int8_t pin) { // 1: output, 0: input
|
||||||
const EPortType samdport = g_APinDescription[pin].ulPort;
|
const EPortType samdport = g_APinDescription[pin].ulPort;
|
||||||
const uint32_t samdpin = g_APinDescription[pin].ulPin;
|
const uint32_t samdpin = g_APinDescription[pin].ulPin;
|
||||||
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
|
return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPWM(const int32_t pin) {
|
void printPinPWM(int32_t pin) {
|
||||||
if (pwm_status(pin)) {
|
if (pwm_status(pin)) {
|
||||||
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
|
||||||
//SERIAL_ECHOPGM("PWM = ", duty);
|
//SERIAL_ECHOPGM("PWM = ", duty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPinPort(const pin_t) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AGCM4 Board pin | PORT | Label
|
* AGCM4 Board pin | PORT | Label
|
||||||
* ----------------+--------+-------
|
* ----------------+--------+-------
|
||||||
|
|||||||
@@ -46,9 +46,14 @@
|
|||||||
#ifndef SD_MOSI_PIN
|
#ifndef SD_MOSI_PIN
|
||||||
#define SD_MOSI_PIN 51
|
#define SD_MOSI_PIN 51
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SDSS
|
||||||
|
#define SDSS 53
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#error "Unsupported board!"
|
#error "Unsupported board!"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SD_SS_PIN SDSS
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ void MarlinHAL::init() {
|
|||||||
constexpr int cpuFreq = F_CPU;
|
constexpr int cpuFreq = F_CPU;
|
||||||
UNUSED(cpuFreq);
|
UNUSED(cpuFreq);
|
||||||
|
|
||||||
#if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && PIN_EXISTS(SD_SS)
|
#if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && (defined(SDSS) && SDSS != -1)
|
||||||
OUT_WRITE(SD_SS_PIN, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PIN_EXISTS(LED)
|
#if PIN_EXISTS(LED)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "temp_soc.h"
|
#include "temp_soc.h"
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include "Servo.h"
|
#include "Servo.h"
|
||||||
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
@@ -42,11 +43,87 @@
|
|||||||
#define CPU_ST7920_DELAY_2 40
|
#define CPU_ST7920_DELAY_2 40
|
||||||
#define CPU_ST7920_DELAY_3 340
|
#define CPU_ST7920_DELAY_3 340
|
||||||
|
|
||||||
//
|
// ------------------------
|
||||||
// Serial Ports
|
// Serial ports
|
||||||
//
|
// ------------------------
|
||||||
|
#ifdef USBCON
|
||||||
|
#include <USBSerial.h>
|
||||||
|
#include "../../core/serial_hook.h"
|
||||||
|
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
|
||||||
|
extern DefaultSerial1 MSerialUSB;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
#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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: review this to return 1 for pins that are not analog input
|
* TODO: review this to return 1 for pins that are not analog input
|
||||||
|
|||||||
@@ -37,17 +37,7 @@
|
|||||||
#include "HardwareSerial.h"
|
#include "HardwareSerial.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
// Prevent selection of LPUART1 on STM32H7xx
|
// USART/UART PIN MAPPING FOR STM32F0/F1/F2/F4/F7
|
||||||
#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
|
#ifndef PIN_SERIAL1_TX
|
||||||
#define PIN_SERIAL1_TX PA9
|
#define PIN_SERIAL1_TX PA9
|
||||||
#endif
|
#endif
|
||||||
@@ -85,6 +75,46 @@
|
|||||||
#define PIN_SERIAL6_RX PC7
|
#define PIN_SERIAL6_RX PC7
|
||||||
#endif
|
#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,
|
// SerialEvent functions are weak, so when the user doesn't define them,
|
||||||
// the linker just sets their address to 0 (which is checked below).
|
// the linker just sets their address to 0 (which is checked below).
|
||||||
#ifdef USING_HW_SERIAL1
|
#ifdef USING_HW_SERIAL1
|
||||||
@@ -131,12 +161,11 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
setRx(PIN_SERIAL1_RX);
|
setRx(PIN_SERIAL1_RX);
|
||||||
setTx(PIN_SERIAL1_TX);
|
setTx(PIN_SERIAL1_TX);
|
||||||
_uart_index = 0;
|
_uart_index = 0;
|
||||||
|
#ifdef DMA2_Stream2
|
||||||
#ifdef DMA2_Stream2 // F2 / F4 / F7 / H7
|
RX_DMA = { USART1, RCC_AHB1Periph_DMA2, 4, DMA2_Stream2 };
|
||||||
RX_DMA = { USART1, 2, DMA2_Stream2 }; // USART, DMA controller no., DMA stream
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef DMA1_Channel5 // F0 / F1
|
#ifdef DMA1_Channel5
|
||||||
RX_DMA = { USART1, 1, DMA1_Channel5 }; // USART, DMA controller no., DMA channel
|
RX_DMA = { USART1, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel5 };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (peripheral == USART2) {
|
else if (peripheral == USART2) {
|
||||||
@@ -144,10 +173,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
setTx(PIN_SERIAL2_TX);
|
setTx(PIN_SERIAL2_TX);
|
||||||
_uart_index = 1;
|
_uart_index = 1;
|
||||||
#ifdef DMA1_Stream5
|
#ifdef DMA1_Stream5
|
||||||
RX_DMA = { USART2, 1, DMA1_Stream5 };
|
RX_DMA = { USART2, RCC_AHB1Periph_DMA1, 4, DMA1_Stream5 };
|
||||||
#endif
|
#endif
|
||||||
#ifdef DMA1_Channel6
|
#ifdef DMA1_Channel6
|
||||||
RX_DMA = { USART2, 1, DMA1_Channel6 };
|
RX_DMA = { USART2, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel6 };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (peripheral == USART3) {
|
else if (peripheral == USART3) {
|
||||||
@@ -155,17 +184,17 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
setTx(PIN_SERIAL3_TX);
|
setTx(PIN_SERIAL3_TX);
|
||||||
_uart_index = 2;
|
_uart_index = 2;
|
||||||
#ifdef DMA1_Stream1
|
#ifdef DMA1_Stream1
|
||||||
RX_DMA = { USART3, 1, DMA1_Stream1 };
|
RX_DMA = { USART3, RCC_AHB1Periph_DMA1, 4, DMA1_Stream1 };
|
||||||
#endif
|
#endif
|
||||||
#ifdef DMA1_Channel3 // F0 has no support for UART3, requires system remapping
|
#ifdef DMA1_Channel3 // F0 has no support for UART3, requires system remapping
|
||||||
RX_DMA = { USART3, 1, DMA1_Channel3 };
|
RX_DMA = { USART3, RCC_AHBPeriph_DMA1, DMA1, DMA1_Channel3 };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USART4 // Only F2 / F4 / F7
|
#ifdef USART4 // Only F2 / F4 / F7
|
||||||
else if (peripheral == USART4) {
|
else if (peripheral == USART4) {
|
||||||
#ifdef DMA1_Stream2
|
#ifdef DMA1_Stream2
|
||||||
RX_DMA = { USART4, 1, DMA1_Stream2 };
|
RX_DMA = { USART4, RCC_AHB1Periph_DMA1, 4, DMA1_Stream2 };
|
||||||
#endif
|
#endif
|
||||||
setRx(PIN_SERIAL4_RX);
|
setRx(PIN_SERIAL4_RX);
|
||||||
setTx(PIN_SERIAL4_TX);
|
setTx(PIN_SERIAL4_TX);
|
||||||
@@ -176,10 +205,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
#ifdef UART4
|
#ifdef UART4
|
||||||
else if (peripheral == UART4) {
|
else if (peripheral == UART4) {
|
||||||
#ifdef DMA1_Stream2
|
#ifdef DMA1_Stream2
|
||||||
RX_DMA = { UART4, 1, DMA1_Stream2 };
|
RX_DMA = { UART4, RCC_AHB1Periph_DMA1, 4, DMA1_Stream2 };
|
||||||
#endif
|
#endif
|
||||||
#ifdef DMA2_Channel3 // STM32F0xx has only 3 UARTs
|
#ifdef DMA2_Channel3 // STM32F0xx has only 3 UARTs
|
||||||
RX_DMA = { UART4, 2, DMA2_Channel3 };
|
RX_DMA = { UART4, RCC_AHBPeriph_DMA2, DMA2, DMA2_Channel3 };
|
||||||
#endif
|
#endif
|
||||||
setRx(PIN_SERIAL4_RX);
|
setRx(PIN_SERIAL4_RX);
|
||||||
setTx(PIN_SERIAL4_TX);
|
setTx(PIN_SERIAL4_TX);
|
||||||
@@ -187,10 +216,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UART5 // Only F2 / F4 / F7 / H7
|
#ifdef UART5 // Only F2 / F4 / F7
|
||||||
else if (peripheral == UART5) {
|
else if (peripheral == UART5) {
|
||||||
#ifdef DMA1_Stream0
|
#ifdef DMA1_Stream0
|
||||||
RX_DMA = { UART5, 1, DMA1_Stream0 };
|
RX_DMA = { UART5, RCC_AHB1Periph_DMA1, 4, DMA1_Stream0 };
|
||||||
#endif
|
#endif
|
||||||
setRx(PIN_SERIAL5_RX);
|
setRx(PIN_SERIAL5_RX);
|
||||||
setTx(PIN_SERIAL5_TX);
|
setTx(PIN_SERIAL5_TX);
|
||||||
@@ -198,10 +227,10 @@ HAL_HardwareSerial::HAL_HardwareSerial(void *peripheral) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USART6 // Only F2 / F4 / F7 / H7
|
#ifdef USART6 // Only F2 / F4 / F7
|
||||||
else if (peripheral == USART6) {
|
else if (peripheral == USART6) {
|
||||||
#ifdef DMA2_Stream1
|
#ifdef DMA2_Stream1
|
||||||
RX_DMA = { USART6, 2, DMA2_Stream1 };
|
RX_DMA = { USART6, RCC_AHB1Periph_DMA2, 4, DMA2_Stream1 };
|
||||||
#endif
|
#endif
|
||||||
setRx(PIN_SERIAL6_RX);
|
setRx(PIN_SERIAL6_RX);
|
||||||
setTx(PIN_SERIAL6_TX);
|
setTx(PIN_SERIAL6_TX);
|
||||||
@@ -242,34 +271,14 @@ void HAL_HardwareSerial::init(PinName _rx, PinName _tx) {
|
|||||||
* @param obj : pointer to serial_t structure
|
* @param obj : pointer to serial_t structure
|
||||||
* @retval last character received
|
* @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 DISABLED(STM32H7xx)
|
if (obj->tx_head == obj->tx_tail) return -1;
|
||||||
|
|
||||||
int HAL_HardwareSerial::_tx_complete_irq(serial_t *obj) {
|
return 0;
|
||||||
// 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 //////////////////////////////////////////////////////////////
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -331,7 +340,7 @@ void HAL_HardwareSerial::update_rx_head() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx, STM32H7xx)
|
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx)
|
||||||
_serial.rx_head = RX_BUFFER_SIZE - RX_DMA.dma_streamRX->NDTR;
|
_serial.rx_head = RX_BUFFER_SIZE - RX_DMA.dma_streamRX->NDTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -343,22 +352,18 @@ void HAL_HardwareSerial::update_rx_head() {
|
|||||||
|
|
||||||
int HAL_HardwareSerial::available() {
|
int HAL_HardwareSerial::available() {
|
||||||
update_rx_head();
|
update_rx_head();
|
||||||
|
|
||||||
return ((unsigned int)(RX_BUFFER_SIZE + _serial.rx_head - _serial.rx_tail)) % RX_BUFFER_SIZE;
|
return ((unsigned int)(RX_BUFFER_SIZE + _serial.rx_head - _serial.rx_tail)) % RX_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int HAL_HardwareSerial::peek() {
|
int HAL_HardwareSerial::peek() {
|
||||||
update_rx_head();
|
update_rx_head();
|
||||||
if (_serial.rx_head == _serial.rx_tail)
|
if (_serial.rx_head == _serial.rx_tail) return -1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
return _serial.rx_buff[_serial.rx_tail];
|
return _serial.rx_buff[_serial.rx_tail];
|
||||||
}
|
}
|
||||||
|
|
||||||
int HAL_HardwareSerial::read() {
|
int HAL_HardwareSerial::read() {
|
||||||
update_rx_head();
|
update_rx_head();
|
||||||
if (_serial.rx_head == _serial.rx_tail)
|
if (_serial.rx_head == _serial.rx_tail) return -1; // No chars if the head isn't ahead of the tail
|
||||||
return -1; // No chars if the head isn't ahead of the tail
|
|
||||||
|
|
||||||
unsigned char c = _serial.rx_buff[_serial.rx_tail];
|
unsigned char c = _serial.rx_buff[_serial.rx_tail];
|
||||||
_serial.rx_tail = (rx_buffer_index_t)(_serial.rx_tail + 1) % RX_BUFFER_SIZE;
|
_serial.rx_tail = (rx_buffer_index_t)(_serial.rx_tail + 1) % RX_BUFFER_SIZE;
|
||||||
@@ -375,18 +380,8 @@ size_t HAL_HardwareSerial::write(uint8_t c) { // Interrupt based wri
|
|||||||
_serial.tx_buff[_serial.tx_head] = c;
|
_serial.tx_buff[_serial.tx_head] = c;
|
||||||
_serial.tx_head = i;
|
_serial.tx_head = i;
|
||||||
|
|
||||||
#ifdef STM32H7xx // Support STM32H7xx with different uart_attach_tx_callback
|
if (!serial_tx_active(&_serial))
|
||||||
if ((!serial_tx_active(&_serial)) && (_serial.tx_head != _serial.tx_tail)) {
|
uart_attach_tx_callback(&_serial, _tx_complete_irq); // Write next byte, launch interrupt
|
||||||
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;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -395,132 +390,57 @@ void HAL_HardwareSerial::flush() {
|
|||||||
while ((_serial.tx_head != _serial.tx_tail)) { /* nada */ } // nop, the interrupt handler will free up space for us
|
while ((_serial.tx_head != _serial.tx_tail)) { /* nada */ } // nop, the interrupt handler will free up space for us
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx, STM32H7xx)
|
#if ANY(STM32F2xx, STM32F4xx, STM32F7xx)
|
||||||
|
|
||||||
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
||||||
|
RCC_AHB1PeriphClockCmd(RX_DMA.dma_rcc, ENABLE); // Enable DMA clock
|
||||||
|
|
||||||
if (RX_DMA.DMA_ID == 1)
|
#ifdef STM32F7xx
|
||||||
__HAL_RCC_DMA1_CLK_ENABLE(); // Enable DMA1 clock
|
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->RDR); // RX peripheral receive address (usart) F7
|
||||||
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
|
#else
|
||||||
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->DR); // DMA stream Peripheral Address Register = USART Data Register
|
RX_DMA.dma_streamRX->PAR = (uint32_t)(&RX_DMA.uart->DR); // RX peripheral address (usart) F2 / F4
|
||||||
#endif
|
#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->M0AR = (uint32_t)_serial.rx_buff; // DMA stream Memory 0 Adress Register = RX buffer address
|
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->NDTR = RX_BUFFER_SIZE; // DMA stream Number of Data Transfer Register
|
|
||||||
|
|
||||||
#if DISABLED(STM32H7xx) // Select channel via CR register
|
RX_DMA.dma_streamRX->CR |= (3 << 16); // RX priority level: Very High
|
||||||
|
|
||||||
RX_DMA.dma_streamRX->CR = 4 << DMA_SxCR_CHSEL_Pos; // DMA stream Channel Selection, always use channel 4
|
//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
|
||||||
#else // STM32H7xx, select channel with DMAMUX1, channel DMA1 is channel DMAMUX, channel DMA2 is channel DMAMUX + 8
|
RX_DMA.dma_streamRX->CR |= (1 << 10); // RX memory increment mode
|
||||||
|
//RX_DMA.dma_streamRX->CR &= ~(1 << 9); // RX peripheral no increment mode
|
||||||
if (RX_DMA.uart == USART1) DMAMUX1_Channel10->CCR |= DMA_REQUEST_USART1_RX; // DMA2, Stream 2
|
RX_DMA.dma_streamRX->CR |= (1 << 8); // RX circular mode enabled
|
||||||
if (RX_DMA.uart == USART2) DMAMUX1_Channel5->CCR |= DMA_REQUEST_USART2_RX; // DMA1, Stream 5
|
//RX_DMA.dma_streamRX->CR &= ~(1 << 6); // RX data transfer direction: Peripheral-to-memory
|
||||||
if (RX_DMA.uart == USART3) DMAMUX1_Channel1->CCR |= DMA_REQUEST_USART3_RX; // DMA1, Stream 1
|
RX_DMA.uart->CR3 |= (1 << 6); // Enable DMA receiver (DMAR)
|
||||||
#ifdef UART4
|
RX_DMA.dma_streamRX->CR |= (1 << 0); // RX enable DMA
|
||||||
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 || STM32H7xx
|
#endif // STM32F2xx || STM32F4xx || STM32F7xx
|
||||||
|
|
||||||
#if ANY(STM32F0xx, STM32F1xx)
|
#if ANY(STM32F0xx, STM32F1xx)
|
||||||
|
|
||||||
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
void HAL_HardwareSerial::Serial_DMA_Read_Enable() {
|
||||||
|
RCC_AHBPeriphClockCmd(RX_DMA.dma_rcc, ENABLE); // enable DMA clock
|
||||||
|
|
||||||
if (RX_DMA.DMA_ID == 1)
|
RX_DMA.dma_channelRX->CPAR = (uint32_t)(&RX_DMA.uart->DR); // RX peripheral address (usart)
|
||||||
__HAL_RCC_DMA1_CLK_ENABLE(); // enable DMA1 clock
|
RX_DMA.dma_channelRX->CMAR = (uint32_t)_serial.rx_buff; // RX destination address (memory)
|
||||||
else
|
RX_DMA.dma_channelRX->CNDTR = RX_BUFFER_SIZE; // RX buffer size
|
||||||
__HAL_RCC_DMA2_CLK_ENABLE(); // enable DMA2 clock
|
|
||||||
|
|
||||||
RX_DMA.dma_channelRX->CCR &= ~USART_CR1_UE; // DMA stream clear/disable
|
RX_DMA.dma_channelRX->CCR = 0; // RX channel selection, set to 0 all the other CR bits
|
||||||
while (RX_DMA.dma_channelRX->CCR & DMA_CCR_EN) { /* just wait for DMA to complete */ }
|
|
||||||
|
|
||||||
// Clear/disable UART and DMA
|
RX_DMA.dma_channelRX->CCR |= (3<<12); // RX priority level: Very High
|
||||||
RX_DMA.uart->CR1 = 0; // UART clear CR1, disable DMA
|
|
||||||
|
|
||||||
// Configure 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
|
||||||
|
|
||||||
#ifdef STM32F0xx
|
RX_DMA.uart->CR3 |= (1<<6); // enable DMA receiver (DMAR)
|
||||||
RX_DMA.dma_channelRX->CPAR = (uint32_t)(&RX_DMA.uart->RDR); // DMA channel Peripheral Address Register = USART Data Register
|
RX_DMA.dma_channelRX->CCR |= (1<<0); // RX enable DMA
|
||||||
#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
|
#endif // STM32F0xx || STM32F1xx
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user