Merge commit '8bd6b60a0141fa892984f2d5b61f06eadbbf9a5f' into look_at_201

This commit is contained in:
Scott Lahteine 2020-01-31 04:22:09 -06:00
commit be642610ae
748 changed files with 16647 additions and 696040 deletions

4
.github/FUNDING.yml vendored
View file

@ -1 +1,3 @@
custom: http://www.thinkyhead.com/donate-to-marlin
github: [thinkyhead]
patreon: thinkyhead
custom: ["http://www.thinkyhead.com/donate-to-marlin"]

103
.github/workflows/test-builds.yml vendored Normal file
View file

@ -0,0 +1,103 @@
#
# test-builds.yml
# Do test builds to catch compile errors
#
name: CI
on:
pull_request:
branches:
- bugfix-2.0.x
- dev-2.1.x
paths-ignore:
- config/**
- data/**
- docs/**
- '**/*.md'
jobs:
test_builds:
runs-on: ubuntu-latest
strategy:
matrix:
test-platform:
# Base Environments
- DUE
- esp32
- linux_native
- megaatmega2560
- teensy31
- teensy35
# Extended AVR Environments
- FYSETC_F6_13
- megaatmega1280
- rambo
- sanguino_atmega1284p
- sanguino_atmega644p
# Extended STM32 Environments
- STM32F103RC_bigtree
- STM32F103RC_bigtree_USB
- STM32F103RE_bigtree
- STM32F103RE_bigtree_USB
- STM32F103RC_fysetc
- jgaurora_a5s_a1
- STM32F103VE_longer
- STM32F407VE_black
- BIGTREE_SKR_PRO
- mks_robin
- ARMED
- FYSETC_S6
# Put lengthy tests last
- LPC1768
- LPC1769
# STM32 with non-STM framework. both broken for now. they should use HAL_STM32 which is working.
#- STM32F4
#- STM32F7
# Non-working environment tests
#- BIGTREE_BTT002
#- at90usb1286_cdc
#- at90usb1286_dfu
#- STM32F103CB_malyan
#- mks_robin_lite
#- mks_robin_mini
#- mks_robin_nano
#- SAMD51_grandcentral_m4
steps:
- name: Select Python 3.7
uses: actions/setup-python@v1
with:
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install PlatformIO
run: |
pip install -U https://github.com/platformio/platformio-core/archive/master.zip
platformio update
- name: Check out the PR
uses: actions/checkout@v2
- name: Run ${{ matrix.test-platform }} Tests
run: |
# Inline tests script
[[ "$GITHUB_REPOSITORY" == "MarlinFirmware/Marlin" ]] || exit 0
chmod +x buildroot/bin/*
chmod +x buildroot/share/tests/*
export PATH=./buildroot/bin/:./buildroot/share/tests/:${PATH}
run_tests . ${{ matrix.test-platform }}

View file

@ -143,7 +143,7 @@
// @section extruder
// This defines the number of extruders
// :[1, 2, 3, 4, 5, 6]
// :[1, 2, 3, 4, 5, 6, 7, 8]
#define EXTRUDERS 1
// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
@ -360,7 +360,8 @@
* -1 : thermocouple with AD595
* 0 : not used
* 1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
* 331 : (3.3V scaled thermistor 1 table)
* 331 : (3.3V scaled thermistor 1 table for MEGA)
* 332 : (3.3V scaled thermistor 1 table for DUE)
* 2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
* 3 : Mendel-parts thermistor (4.7k pullup)
* 4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
@ -411,7 +412,10 @@
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 0
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
// Dummy thermistor constant temperature readings, for use with 998 and 999
@ -439,6 +443,8 @@
#define HEATER_3_MINTEMP 5
#define HEATER_4_MINTEMP 5
#define HEATER_5_MINTEMP 5
#define HEATER_6_MINTEMP 5
#define HEATER_7_MINTEMP 5
#define BED_MINTEMP 5
// Above this temperature the heater will be switched off.
@ -450,6 +456,8 @@
#define HEATER_3_MAXTEMP 275
#define HEATER_4_MAXTEMP 275
#define HEATER_5_MAXTEMP 275
#define HEATER_6_MAXTEMP 275
#define HEATER_7_MAXTEMP 275
#define BED_MAXTEMP 150
//===========================================================================
@ -654,12 +662,13 @@
*
* A4988 is assumed for unspecified drivers.
*
* Options: A4988, A5984, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100,
* Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01,
* TB6560, TB6600, TMC2100,
* TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE,
* TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE,
* TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE,
* TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
* :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
*/
//#define X_DRIVER_TYPE A4988
//#define Y_DRIVER_TYPE A4988
@ -668,12 +677,15 @@
//#define Y2_DRIVER_TYPE A4988
//#define Z2_DRIVER_TYPE A4988
//#define Z3_DRIVER_TYPE A4988
//#define Z4_DRIVER_TYPE A4988
//#define E0_DRIVER_TYPE A4988
//#define E1_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988
//#define E3_DRIVER_TYPE A4988
//#define E4_DRIVER_TYPE A4988
//#define E5_DRIVER_TYPE A4988
//#define E6_DRIVER_TYPE A4988
//#define E7_DRIVER_TYPE A4988
// Enable this feature if all enabled endstop pins are interrupt-capable.
// This will remove the need to poll the interrupt pins, saving many CPU cycles.
@ -903,6 +915,13 @@
#define Z_PROBE_RETRACT_X X_MAX_POS
#endif
// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
// When the pin is defined you can use M672 to set/reset the probe sensivity.
//#define DUET_SMART_EFFECTOR
#if ENABLED(DUET_SMART_EFFECTOR)
#define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin
#endif
//
// For Z_PROBE_ALLEN_KEY see the Delta example configurations.
//
@ -929,7 +948,8 @@
*/
#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
// Certain types of probes need to stay away from edges
// Most probes should stay away from the edges of the bed, but
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
#define MIN_PROBE_EDGE 10
// X and Y axis travel speed (mm/m) between probes
@ -1039,6 +1059,8 @@
#define INVERT_E3_DIR false
#define INVERT_E4_DIR false
#define INVERT_E5_DIR false
#define INVERT_E6_DIR false
#define INVERT_E7_DIR false
// @section homing
@ -1424,11 +1446,6 @@
#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113.
#define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating
//
// M100 Free Memory Watcher
//
//#define M100_FREE_MEMORY_WATCHER // Add M100 (Free Memory Watcher) to debug memory usage
//
// G20/G21 Inch mode support
//
@ -1519,9 +1536,10 @@
// Default number of triangles
#define NOZZLE_CLEAN_TRIANGLES 3
// Specify positions as { X, Y, Z }
#define NOZZLE_CLEAN_START_POINT { 30, 30, (Z_MIN_POS + 1) }
#define NOZZLE_CLEAN_END_POINT { 100, 60, (Z_MIN_POS + 1) }
// Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
// Dual hotend system may use { { -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }, { 420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
#define NOZZLE_CLEAN_START_POINT { { 30, 30, (Z_MIN_POS + 1) } }
#define NOZZLE_CLEAN_END_POINT { { 100, 60, (Z_MIN_POS + 1) } }
// Circular pattern radius
#define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5
@ -1946,6 +1964,7 @@
//#define FYSETC_MINI_12864_1_2 // Type C/D/E/F. Simple RGB Backlight (always on)
//#define FYSETC_MINI_12864_2_0 // Type A/B. Discreet RGB Backlight
//#define FYSETC_MINI_12864_2_1 // Type A/B. Neopixel RGB Backlight
//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
//
// Factory display for Creality CR-10
@ -1956,6 +1975,11 @@
//
//#define CR10_STOCKDISPLAY
//
// Ender-2 OEM display, a variant of the MKS_MINI_12864
//
//#define ENDER2_STOCKDISPLAY
//
// ANET and Tronxy Graphical Controller
//
@ -2024,9 +2048,11 @@
//=============================================================================
//
// DGUS Touch Display with DWIN OS
// DGUS Touch Display with DWIN OS. (Choose one.)
//
//#define DGUS_LCD
//#define DGUS_LCD_UI_ORIGIN
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY
//
// Touch-screen LCD for Malyan M200 printers

View file

@ -78,6 +78,18 @@
#define HOTEND5_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_6 == 1000
#define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND6_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_7 == 1000
#define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define HOTEND7_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_BED == 1000
#define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
@ -368,7 +380,7 @@
* FAST_PWM_FAN_FREQUENCY [undefined by default]
* Set this to your desired frequency.
* If left undefined this defaults to F = F_CPU/(2*255*1)
* ie F = 31.4 Khz on 16 MHz microcontrollers or F = 39.2 KHz on 20 MHz microcontrollers
* i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
* These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
* NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
*
@ -479,7 +491,7 @@
//#define X_DUAL_ENDSTOPS
#if ENABLED(X_DUAL_ENDSTOPS)
#define X2_USE_ENDSTOP _XMAX_
#define X_DUAL_ENDSTOPS_ADJUSTMENT 0
#define X2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
@ -489,27 +501,28 @@
//#define Y_DUAL_ENDSTOPS
#if ENABLED(Y_DUAL_ENDSTOPS)
#define Y2_USE_ENDSTOP _YMAX_
#define Y_DUAL_ENDSTOPS_ADJUSTMENT 0
#define Y2_ENDSTOP_ADJUSTMENT 0
#endif
#endif
//#define Z_DUAL_STEPPER_DRIVERS
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
//#define Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_
#define Z_DUAL_ENDSTOPS_ADJUSTMENT 0
#endif
#endif
//
// For Z set the number of stepper drivers
//
#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many
//#define Z_TRIPLE_STEPPER_DRIVERS
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
//#define Z_TRIPLE_ENDSTOPS
#if ENABLED(Z_TRIPLE_ENDSTOPS)
#if NUM_Z_STEPPER_DRIVERS > 1
//#define Z_MULTI_ENDSTOPS
#if ENABLED(Z_MULTI_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_
#define Z2_ENDSTOP_ADJUSTMENT 0
#if NUM_Z_STEPPER_DRIVERS >= 3
#define Z3_USE_ENDSTOP _YMAX_
#define Z_TRIPLE_ENDSTOPS_ADJUSTMENT2 0
#define Z_TRIPLE_ENDSTOPS_ADJUSTMENT3 0
#define Z3_ENDSTOP_ADJUSTMENT 0
#endif
#if NUM_Z_STEPPER_DRIVERS >= 4
#define Z4_USE_ENDSTOP _ZMAX_
#define Z4_ENDSTOP_ADJUSTMENT 0
#endif
#endif
#endif
@ -1243,6 +1256,44 @@
#endif // HAS_GRAPHICAL_LCD
//
// Additional options for DGUS / DWIN displays
//
#if HAS_DGUS_LCD
#define DGUS_SERIAL_PORT 2
#define DGUS_BAUDRATE 115200
#define DGUS_RX_BUFFER_SIZE 128
#define DGUS_TX_BUFFER_SIZE 48
//#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
#define BOOTSCREEN_TIMEOUT 3000 // (ms) Duration to display the boot screen
#if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
#define DGUS_PRINT_FILENAME // Display the filename during printing
#define DGUS_PREHEAT_UI // Display a preheat screen during heatup
#if ENABLED(DGUS_LCD_UI_FYSETC)
//#define DUGS_UI_MOVE_DIS_OPTION // Disabled by default for UI_FYSETC
#else
#define DUGS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY
#endif
#define DGUS_FILAMENT_LOADUNLOAD
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
#define DGUS_FILAMENT_PURGE_LENGTH 10
#define DGUS_FILAMENT_LOAD_LENGTH_PER_TIME 0.5 // (mm) Adjust in proportion to DGUS_UPDATE_INTERVAL_MS
#endif
#define DGUS_UI_WAITING // Show a "waiting" screen between some screens
#if ENABLED(DGUS_UI_WAITING)
#define DGUS_UI_WAITING_STATUS 10
#define DGUS_UI_WAITING_STATUS_PERIOD 8 // Increase to slower waiting status looping
#endif
#endif
#endif // HAS_DGUS_LCD
//
// Touch UI for the FTDI Embedded Video Engine (EVE)
//
@ -1341,6 +1392,13 @@
//#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
#endif
//
// ADC Button Debounce
//
#if HAS_ADC_BUTTONS
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (ms) Increase if buttons bounce or repeat too fast
#endif
// @section safety
/**
@ -1438,7 +1496,8 @@
* Override MIN_PROBE_EDGE for each side of the build plate
* Useful to get probe points to exact positions on targets or
* to allow leveling to avoid plate clamps on only specific
* sides of the bed.
* sides of the bed. With NOZZLE_AS_PROBE negative values are
* allowed, to permit probing outside the bed.
*
* If you are replacing the prior *_PROBE_BED_POSITION options,
* LEFT and FRONT values in most cases will map directly over
@ -1483,15 +1542,54 @@
#endif
/**
* Thermal Probe Compensation
* Probe measurements are adjusted to compensate for temperature distortion.
* Use G76 to calibrate this feature. Use M871 to set values manually.
* For a more detailed explanation of the process see G76_M871.cpp.
*/
#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
// Enable thermal first layer compensation using bed and probe temperatures
#define PROBE_TEMP_COMPENSATION
// Add additional compensation depending on hotend temperature
// Note: this values cannot be calibrated and have to be set manually
#ifdef PROBE_TEMP_COMPENSATION
// Max temperature that can be reached by heated bed.
// This is required only for the calibration process.
#define PTC_MAX_BED_TEMP 110
// Park position to wait for probe cooldown
#define PTC_PARK_POS_X 0.0F
#define PTC_PARK_POS_Y 0.0F
#define PTC_PARK_POS_Z 100.0F
// Probe position to probe and wait for probe to reach target temperature
#define PTC_PROBE_POS_X 90.0F
#define PTC_PROBE_POS_Y 100.0F
// Enable additional compensation using hotend temperature
// Note: this values cannot be calibrated automatically but have to be set manually
//#define USE_TEMP_EXT_COMPENSATION
#endif
#endif
// @section extras
//
// G60/G61 Position Save and Return
//
//#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes
//
// G2/G3 Arc Support
//
#define ARC_SUPPORT // Disable this feature to save ~3226 bytes
#if ENABLED(ARC_SUPPORT)
#define MM_PER_ARC_SEGMENT 1 // Length of each arc segment
#define MM_PER_ARC_SEGMENT 1 // (mm) Length (or minimum length) of each arc segment
//#define ARC_SEGMENTS_PER_R 1 // Max segment length, MM_PER = Min
#define MIN_ARC_SEGMENTS 24 // Minimum number of segments in a complete circle
//#define ARC_SEGMENTS_PER_SEC 50 // Use feedrate to choose segment length (with MM_PER_ARC_SEGMENT as the minimum)
#define N_ARC_CORRECTION 25 // Number of interpolated segments between corrections
//#define ARC_P_CIRCLES // Enable the 'P' parameter to specify complete circles
//#define CNC_WORKSPACE_PLANES // Allow G2/G3 to operate in XY, ZX, or YZ planes
@ -1691,6 +1789,9 @@
// Z raise distance for tool-change, as needed for some extruders
#define TOOLCHANGE_ZRAISE 2 // (mm)
//#define TOOLCHANGE_NO_RETURN // Never return to the previous position on tool-change
#if ENABLED(TOOLCHANGE_NO_RETURN)
//#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // G-code to run after tool-change is complete
#endif
// Retract and prime filament on tool-change
//#define TOOLCHANGE_FILAMENT_SWAP
@ -1754,6 +1855,7 @@
#define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length.
#define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.
#define FILAMENT_UNLOAD_PURGE_FEEDRATE 25 // (mm/s) feedrate to purge before unload
#define PAUSE_PARK_NOZZLE_TIMEOUT 45 // (seconds) Time limit before the nozzle is turned off for safety.
#define FILAMENT_CHANGE_ALERT_BEEPS 10 // Number of alert beeps to play when a response is needed.
@ -1818,6 +1920,12 @@
#define Z3_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_Z4(TMC26X)
#define Z4_MAX_CURRENT 1000
#define Z4_SENSE_RESISTOR 91
#define Z4_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E0(TMC26X)
#define E0_MAX_CURRENT 1000
#define E0_SENSE_RESISTOR 91
@ -1854,6 +1962,18 @@
#define E5_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E6(TMC26X)
#define E6_MAX_CURRENT 1000
#define E6_SENSE_RESISTOR 91
#define E6_MICROSTEPS 16
#endif
#if AXIS_DRIVER_TYPE_E7(TMC26X)
#define E7_MAX_CURRENT 1000
#define E7_SENSE_RESISTOR 91
#define E7_MICROSTEPS 16
#endif
#endif // TMC26X
// @section tmc_smart
@ -1935,6 +2055,14 @@
#define Z3_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(Z4)
#define Z4_CURRENT 800
#define Z4_CURRENT_HOME Z4_CURRENT
#define Z4_MICROSTEPS 16
#define Z4_RSENSE 0.11
#define Z4_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E0)
#define E0_CURRENT 800
#define E0_MICROSTEPS 16
@ -1977,6 +2105,20 @@
#define E5_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E6)
#define E6_CURRENT 800
#define E6_MICROSTEPS 16
#define E6_RSENSE 0.11
#define E6_CHAIN_POS -1
#endif
#if AXIS_IS_TMC(E7)
#define E7_CURRENT 800
#define E7_MICROSTEPS 16
#define E7_RSENSE 0.11
#define E7_CHAIN_POS -1
#endif
/**
* Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here.
* The default pins can be found in your board's pins file.
@ -1994,6 +2136,8 @@
//#define E3_CS_PIN -1
//#define E4_CS_PIN -1
//#define E5_CS_PIN -1
//#define E6_CS_PIN -1
//#define E7_CS_PIN -1
/**
* Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160).
@ -2024,12 +2168,15 @@
#define Y2_SLAVE_ADDRESS 0
#define Z2_SLAVE_ADDRESS 0
#define Z3_SLAVE_ADDRESS 0
#define Z4_SLAVE_ADDRESS 0
#define E0_SLAVE_ADDRESS 0
#define E1_SLAVE_ADDRESS 0
#define E2_SLAVE_ADDRESS 0
#define E3_SLAVE_ADDRESS 0
#define E4_SLAVE_ADDRESS 0
#define E5_SLAVE_ADDRESS 0
#define E6_SLAVE_ADDRESS 0
#define E7_SLAVE_ADDRESS 0
/**
* Software enable
@ -2099,12 +2246,15 @@
#define Z_HYBRID_THRESHOLD 3
#define Z2_HYBRID_THRESHOLD 3
#define Z3_HYBRID_THRESHOLD 3
#define Z4_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
#define E1_HYBRID_THRESHOLD 30
#define E2_HYBRID_THRESHOLD 30
#define E3_HYBRID_THRESHOLD 30
#define E4_HYBRID_THRESHOLD 30
#define E5_HYBRID_THRESHOLD 30
#define E6_HYBRID_THRESHOLD 30
#define E7_HYBRID_THRESHOLD 30
/**
* Use StallGuard2 to home / probe X, Y, Z.
@ -2176,12 +2326,12 @@
#endif // HAS_TRINAMIC
// @section L6470
// @section L64XX
/**
* L6470 Stepper Driver options
* L64XX Stepper Driver options
*
* Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver.
* Arduino-L6470 library (0.8.0 or higher) is required.
* https://github.com/ameyer/Arduino-L6470
*
* Requires the following to be defined in your pins_YOUR_BOARD file
@ -2189,114 +2339,160 @@
* L6470_CHAIN_MISO_PIN
* L6470_CHAIN_MOSI_PIN
* L6470_CHAIN_SS_PIN
* L6470_RESET_CHAIN_PIN (optional)
* ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset
*/
#if HAS_DRIVER(L6470)
#if HAS_L64XX
//#define L6470_CHITCHAT // Display additional status info
#if AXIS_DRIVER_TYPE_X(L6470)
#define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128)
#define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current (VALID: 375 x (1 - 16) - 6A max - rounds down)
#if AXIS_IS_L64XX(X)
#define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16
#define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current
// L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down
// POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down
#define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down)
#define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper
#define X_CHAIN_POS -1 // Position in SPI chain. (<=0 : Not in chain. 1 : Nearest MOSI)
// L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down
// POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down
// L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current
#define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474
#define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
#define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest
#endif
#if AXIS_DRIVER_TYPE_X2(L6470)
#if AXIS_IS_L64XX(X2)
#define X2_MICROSTEPS 128
#define X2_OVERCURRENT 2000
#define X2_STALLCURRENT 1500
#define X2_MAX_VOLTAGE 127
#define X2_CHAIN_POS -1
#define X2_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_Y(L6470)
#if AXIS_IS_L64XX(Y)
#define Y_MICROSTEPS 128
#define Y_OVERCURRENT 2000
#define Y_STALLCURRENT 1500
#define Y_MAX_VOLTAGE 127
#define Y_CHAIN_POS -1
#define Y_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_Y2(L6470)
#if AXIS_IS_L64XX(Y2)
#define Y2_MICROSTEPS 128
#define Y2_OVERCURRENT 2000
#define Y2_STALLCURRENT 1500
#define Y2_MAX_VOLTAGE 127
#define Y2_CHAIN_POS -1
#define Y2_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_Z(L6470)
#if AXIS_IS_L64XX(Z)
#define Z_MICROSTEPS 128
#define Z_OVERCURRENT 2000
#define Z_STALLCURRENT 1500
#define Z_MAX_VOLTAGE 127
#define Z_CHAIN_POS -1
#define Z_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_Z2(L6470)
#if AXIS_IS_L64XX(Z2)
#define Z2_MICROSTEPS 128
#define Z2_OVERCURRENT 2000
#define Z2_STALLCURRENT 1500
#define Z2_MAX_VOLTAGE 127
#define Z2_CHAIN_POS -1
#define Z2_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_Z3(L6470)
#if AXIS_IS_L64XX(Z3)
#define Z3_MICROSTEPS 128
#define Z3_OVERCURRENT 2000
#define Z3_STALLCURRENT 1500
#define Z3_MAX_VOLTAGE 127
#define Z3_CHAIN_POS -1
#define Z3_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E0(L6470)
#if AXIS_IS_L64XX(Z4)
#define Z4_MICROSTEPS 128
#define Z4_OVERCURRENT 2000
#define Z4_STALLCURRENT 1500
#define Z4_MAX_VOLTAGE 127
#define Z4_CHAIN_POS -1
#define Z4_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E0)
#define E0_MICROSTEPS 128
#define E0_OVERCURRENT 2000
#define E0_STALLCURRENT 1500
#define E0_MAX_VOLTAGE 127
#define E0_CHAIN_POS -1
#define E0_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E1(L6470)
#if AXIS_IS_L64XX(E1)
#define E1_MICROSTEPS 128
#define E1_OVERCURRENT 2000
#define E1_STALLCURRENT 1500
#define E1_MAX_VOLTAGE 127
#define E1_CHAIN_POS -1
#define E1_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E2(L6470)
#if AXIS_IS_L64XX(E2)
#define E2_MICROSTEPS 128
#define E2_OVERCURRENT 2000
#define E2_STALLCURRENT 1500
#define E2_MAX_VOLTAGE 127
#define E2_CHAIN_POS -1
#define E2_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E3(L6470)
#if AXIS_IS_L64XX(E3)
#define E3_MICROSTEPS 128
#define E3_OVERCURRENT 2000
#define E3_STALLCURRENT 1500
#define E3_MAX_VOLTAGE 127
#define E3_CHAIN_POS -1
#define E3_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E4(L6470)
#if AXIS_IS_L64XX(E4)
#define E4_MICROSTEPS 128
#define E4_OVERCURRENT 2000
#define E4_STALLCURRENT 1500
#define E4_MAX_VOLTAGE 127
#define E4_CHAIN_POS -1
#define E4_SLEW_RATE 1
#endif
#if AXIS_DRIVER_TYPE_E5(L6470)
#if AXIS_IS_L64XX(E5)
#define E5_MICROSTEPS 128
#define E5_OVERCURRENT 2000
#define E5_STALLCURRENT 1500
#define E5_MAX_VOLTAGE 127
#define E5_CHAIN_POS -1
#define E5_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E6)
#define E6_MICROSTEPS 128
#define E6_OVERCURRENT 2000
#define E6_STALLCURRENT 1500
#define E6_MAX_VOLTAGE 127
#define E6_CHAIN_POS -1
#define E6_SLEW_RATE 1
#endif
#if AXIS_IS_L64XX(E7)
#define E7_MICROSTEPS 128
#define E7_OVERCURRENT 2000
#define E7_STALLCURRENT 1500
#define E7_MAX_VOLTAGE 127
#define E7_CHAIN_POS -1
#define E7_SLEW_RATE 1
#endif
/**
@ -2308,7 +2504,7 @@
* I not present or I0 or I1 - X, Y, Z or E0
* I2 - X2, Y2, Z2 or E1
* I3 - Z3 or E3
* I4 - E4
* I4 - Z4 or E4
* I5 - E5
* M916 - Increase drive level until get thermal warning
* M917 - Find minimum current thresholds
@ -2322,7 +2518,15 @@
//#define L6470_STOP_ON_ERROR
#endif
#endif // L6470
#endif // HAS_L64XX
// @section i2cbus
//
// I2C Master ID for LPC176x LCD and Digital Current control
// Does not apply to other peripherals based on the Wire library.
//
//#define I2C_MASTER_ID 1 // Set a value from 0 to 2
/**
* TWI/I2C BUS
@ -2352,10 +2556,10 @@
* echo:i2c-reply: from:99 bytes:5 data:hello
*/
// @section i2cbus
//#define EXPERIMENTAL_I2CBUS
#if ENABLED(EXPERIMENTAL_I2CBUS)
#define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave
#endif
// @section extras
@ -2384,6 +2588,20 @@
// Duration to hold the switch or keep CHDK_PIN high
//#define PHOTO_SWITCH_MS 50 // (ms) (M240 D)
/**
* PHOTO_PULSES_US may need adjustment depending on board and camera model.
* Pin must be running at 48.4kHz.
* Be sure to use a PHOTOGRAPH_PIN which can rise and fall quick enough.
* (e.g., MKS SBase temp sensor pin was too slow, so used P1.23 on J8.)
*
* Example pulse data for Nikon: https://bit.ly/2FKD0Aq
* IR Wiring: https://git.io/JvJf7
*/
//#define PHOTO_PULSES_US { 2000, 27850, 400, 1580, 400, 3580, 400 } // (µs) Durations for each 48.4kHz oscillation
#ifdef PHOTO_PULSES_US
#define PHOTO_PULSE_DELAY_US 13 // (µs) Approximate duration of each HIGH and LOW pulse in the oscillation
#endif
#endif
/**
@ -2723,7 +2941,11 @@
#define JOY_Z_PIN 12 // RAMPS: Suggested pin A12 on AUX2
#define JOY_EN_PIN 44 // RAMPS: Suggested pin D44 on AUX2
// Use M119 to find reasonable values after connecting your hardware:
//#define INVERT_JOY_X // Enable if X direction is reversed
//#define INVERT_JOY_Y // Enable if Y direction is reversed
//#define INVERT_JOY_Z // Enable if Z direction is reversed
// Use M119 with JOYSTICK_DEBUG to find reasonable values after connecting:
#define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max
#define JOY_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
@ -2778,12 +3000,15 @@
/**
* WiFi Support (Espressif ESP32 WiFi)
*/
//#define WIFISUPPORT
#if ENABLED(WIFISUPPORT)
//#define WIFISUPPORT // Marlin embedded WiFi managenent
//#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
#define WIFI_SSID "Wifi SSID"
#define WIFI_PWD "Wifi Password"
//#define WEBSUPPORT // Start a webserver with auto-discovery
//#define WEBSUPPORT // Start a webserver (which may include auto-discovery)
//#define OTASUPPORT // Support over-the-air firmware updates
//#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
#endif
/**
@ -2855,9 +3080,14 @@
// @section develop
/**
* M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
*/
//
// M100 Free Memory Watcher to debug memory usage
//
//#define M100_FREE_MEMORY_WATCHER
//
// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
//
//#define PINS_DEBUGGING
// Enable Marlin dev mode which adds some special commands

View file

@ -91,24 +91,37 @@ typedef int8_t pin_t;
#define NUM_SERIAL 1
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3"
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#define MYSERIAL0 customizedSerial1
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3"
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#endif
#define NUM_SERIAL 2
#define MYSERIAL1 customizedSerial2
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#endif
#ifdef DGUS_SERIAL_PORT
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif
#define DGUS_SERIAL internalDgusSerial
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
#endif
// ------------------------
// Public functions
// ------------------------
@ -345,9 +358,9 @@ void TIMER0_COMPB_vect_bottom()
// ADC
#ifdef DIDR2
#define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0)
#define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
#else
#define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
#define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
#endif
inline void HAL_adc_init() {
@ -358,11 +371,11 @@ inline void HAL_adc_init() {
#endif
}
#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
#ifdef MUX5
#define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
#define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#else
#define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
#define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
#endif
#define HAL_ADC_RESOLUTION 10

View file

@ -41,7 +41,7 @@
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
#include "MarlinSerial.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };
@ -757,6 +757,33 @@
#endif
#ifdef DGUS_SERIAL_PORT
template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
h = tx_buffer.head; // next pos for queue.
int ret = t - h - 1;
if (ret < 0) ret += Cfg::TX_SIZE + 1;
return ret;
}
ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_RX_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::store_rxd_char();
}
ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::_tx_udr_empty_irq();
}
// Preinstantiate
template class MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>;
// Instantiate
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
#endif
// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;

View file

@ -217,6 +217,9 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
#ifdef DGUS_SERIAL_PORT
static ring_buffer_pos_t get_tx_buffer_free();
#endif
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
@ -292,6 +295,23 @@
extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
#endif
#ifdef DGUS_SERIAL_PORT
template <uint8_t serial>
struct MarlinInternalSerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = 128;
static constexpr unsigned int TX_SIZE = 48;
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_OVERRUNS = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
};
extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
#endif
// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;

View file

@ -232,6 +232,22 @@ void setup_endstop_interrupts() {
pciSetup(Z3_MIN_PIN);
#endif
#endif
#if HAS_Z4_MAX
#if (digitalPinToInterrupt(Z4_MAX_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z4_MAX_PIN);
#else
static_assert(digitalPinHasPCICR(Z4_MAX_PIN), "Z4_MAX_PIN is not interrupt-capable");
pciSetup(Z4_MAX_PIN);
#endif
#endif
#if HAS_Z4_MIN
#if (digitalPinToInterrupt(Z4_MIN_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z4_MIN_PIN);
#else
static_assert(digitalPinHasPCICR(Z4_MIN_PIN), "Z4_MIN_PIN is not interrupt-capable");
pciSetup(Z4_MIN_PIN);
#endif
#endif
#if HAS_Z_MIN_PROBE_PIN
#if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
_ATTACH(Z_MIN_PROBE_PIN);

View file

@ -279,14 +279,25 @@ enum ClockSource2 : char {
*/
// Determine which harware PWMs are already in use
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#if PIN_EXISTS(CONTROLLER_FAN)
#define PWM_CHK_FAN_B(P) (P == CONTROLLER_FAN_PIN || P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
#else
#define PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
#define PWM_CHK_FAN_B(P) _PWM_CHK_FAN_B(P)
#endif
#if ANY_PIN(FAN, FAN1, FAN2)
#if PIN_EXISTS(FAN2)
#if ANY_PIN(FAN, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7)
#if PIN_EXISTS(FAN7)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN || P == FAN7_PIN)
#elif PIN_EXISTS(FAN6)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN)
#elif PIN_EXISTS(FAN5)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN)
#elif PIN_EXISTS(FAN4)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN)
#elif PIN_EXISTS(FAN3)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN)
#elif PIN_EXISTS(FAN2)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN)
#elif PIN_EXISTS(FAN1)
#define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN)

View file

@ -59,3 +59,7 @@
#if HAS_TRINAMIC && ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
#error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif
#if TMC_HAS_SW_SERIAL && ENABLED(MONITOR_DRIVER_STATUS)
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
#endif

View file

@ -231,11 +231,10 @@ static void err_is_interrupt() { SERIAL_ECHOPGM(" compare interrupt enabled"
static void err_prob_interrupt() { SERIAL_ECHOPGM(" overflow interrupt enabled"); }
static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); SERIAL_ECHO_SP(14); }
void com_print(uint8_t N, uint8_t Z) {
inline void com_print(const uint8_t N, const uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPGM(" COM");
SERIAL_CHAR('0' + N);
SERIAL_CHAR('A' + Z);
SERIAL_CHAR('0' + N, Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}
@ -247,8 +246,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
SERIAL_ECHOPGM(" TIMER");
SERIAL_CHAR(T + '0');
SERIAL_CHAR(L);
SERIAL_CHAR(T + '0', L);
SERIAL_ECHO_SP(3);
if (N == 3) {

View file

@ -28,7 +28,7 @@
#include "watchdog.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
// Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
void watchdog_init() {

View file

@ -94,8 +94,8 @@ int freeMemory() {
// ADC
// ------------------------
void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = analogRead(adc_pin);
void HAL_adc_start_conversion(const uint8_t ch) {
HAL_adc_result = analogRead(ch);
}
uint16_t HAL_adc_get_result() {

View file

@ -56,8 +56,7 @@
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
#endif
#if SERIAL_PORT_2 == -1
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 customizedSerial2
#elif SERIAL_PORT_2 == 0
#define MYSERIAL1 Serial
@ -75,6 +74,27 @@
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL internalDgusSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL Serial3
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
#include "MarlinSerial.h"
#include "MarlinSerialUSB.h"
@ -128,16 +148,16 @@ extern uint16_t HAL_adc_result; // result of last ADC conversion
#define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
#endif
#define HAL_ANALOG_SELECT(pin)
#define HAL_ANALOG_SELECT(ch)
inline void HAL_adc_init() {}//todo
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
#define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(const uint8_t adc_pin);
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();
//

View file

@ -240,7 +240,7 @@
}
// all the others
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4uS => 125khz
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
int bits = 8;

View file

@ -31,7 +31,7 @@
#include "MarlinSerial.h"
#include "InterruptVectors.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };

View file

@ -63,7 +63,7 @@
#include <U8glib.h>
#include "../../../Marlin.h"
#include "../../../MarlinCore.h"
void spiBegin();
void spiInit(uint8_t spiRate);

View file

@ -77,6 +77,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif

View file

@ -55,3 +55,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -1479,7 +1479,7 @@ static void udd_ctrl_in_sent(void)
// The IN data don't must be written in endpoint 0 DPRAM during
// a next setup reception in same endpoint 0 DPRAM.
// Thereby, an OUT ZLP reception must check before IN data write
// and if no OUT ZLP is recevied the data must be written quickly (800us)
// and if no OUT ZLP is received the data must be written quickly (800µs)
// before an eventually ZLP OUT and SETUP reception
flags = cpu_irq_save();
if (Is_udd_out_received(0)) {

View file

@ -23,7 +23,7 @@
#ifdef ARDUINO_ARCH_SAM
#include "../../inc/MarlinConfig.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
#include "watchdog.h"
// Override Arduino runtime to either config or disable the watchdog

View file

@ -30,10 +30,6 @@
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(WEBSUPPORT)
#include "spiffs.h"
#endif
#if ENABLED(WIFISUPPORT)
#include <ESPAsyncWebServer.h>
#include "wifi.h"
@ -41,6 +37,7 @@
#include "ota.h"
#endif
#if ENABLED(WEBSUPPORT)
#include "spiffs.h"
#include "web.h"
#endif
#endif
@ -78,21 +75,32 @@ volatile int numPWMUsed = 0,
// Public functions
// ------------------------
void HAL_init() {
i2s_init();
#if ENABLED(WIFI_CUSTOM_COMMAND)
bool wifi_custom_command(char * const command_ptr) {
#if ENABLED(ESP3D_WIFISUPPORT)
return esp3dlib.parse(command_ptr);
#else
UNUSED(command_ptr);
return false;
#endif
}
void HAL_init_board() {
#if ENABLED(WEBSUPPORT)
spiffs_init();
#endif
#if ENABLED(WIFISUPPORT)
void HAL_init() { i2s_init(); }
void HAL_init_board() {
#if ENABLED(ESP3D_WIFISUPPORT)
esp3dlib.init();
#elif ENABLED(WIFISUPPORT)
wifi_init();
#if ENABLED(OTASUPPORT)
OTA_init();
#endif
#if ENABLED(WEBSUPPORT)
spiffs_init();
web_init();
#endif
server.begin();
@ -100,9 +108,12 @@ void HAL_init_board() {
}
void HAL_idletask() {
#if ENABLED(OTASUPPORT)
#if BOTH(WIFISUPPORT, OTASUPPORT)
OTA_handle();
#endif
#if ENABLED(ESP3D_WIFISUPPORT)
esp3dlib.idletask();
#endif
}
void HAL_clear_reset_source() { }
@ -183,7 +194,7 @@ void HAL_adc_init() {
}
}
void HAL_adc_start_conversion(uint8_t adc_pin) {
void HAL_adc_start_conversion(const uint8_t adc_pin) {
const adc1_channel_t chan = get_channel(adc_pin);
uint32_t mv;
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);

View file

@ -36,7 +36,14 @@
#include "timers.h"
#if ENABLED(WIFISUPPORT)
#include "WebSocketSerial.h"
#endif
#if ENABLED(ESP3D_WIFISUPPORT)
#include "esp3dlib.h"
#endif
#include "FlushableHardwareSerial.h"
// ------------------------
@ -47,9 +54,13 @@ extern portMUX_TYPE spinlock;
#define MYSERIAL0 flushableSerial
#if ENABLED(WIFISUPPORT)
#define NUM_SERIAL 2
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
#if ENABLED(ESP3D_WIFISUPPORT)
#define MYSERIAL1 Serial2Socket
#else
#define MYSERIAL1 webSocketSerial
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
@ -60,7 +71,6 @@ extern portMUX_TYPE spinlock;
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
// Fix bug in pgm_read_ptr
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
@ -115,7 +125,7 @@ void HAL_adc_init();
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(uint8_t adc_pin);
void HAL_adc_start_conversion(const uint8_t adc_pin);
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
@ -127,3 +137,44 @@ void HAL_adc_start_conversion(uint8_t adc_pin);
void HAL_idletask();
void HAL_init();
void HAL_init_board();
//
// Delay in cycles (used by DELAY_NS / DELAY_US)
//
FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
unsigned long start, ccount, stop;
/**
* It's important to care for race conditions (and overflows) here.
* Race condition example: If `stop` calculates to being close to the upper boundary of
* `uint32_t` and if at the same time a longer loop interruption kicks in (e.g. due to other
* FreeRTOS tasks or interrupts), `ccount` might overflow (and therefore be below `stop` again)
* without the loop ever being able to notice that `ccount` had already been above `stop` once
* (and that therefore the number of cycles to delay has already passed).
* As DELAY_CYCLES (through DELAY_NS / DELAY_US) is used by software SPI bit banging to drive
* LCDs and therefore might be called very, very often, this seemingly improbable situation did
* actually happen in reality. It resulted in apparently random print pauses of ~17.9 seconds
* (0x100000000 / 240 MHz) or multiples thereof, essentially ruining the current print by causing
* large blobs of filament.
*/
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (start) );
stop = start + x;
ccount = start;
if (stop >= start) {
// no overflow, so only loop while in between start and stop:
// 0x00000000 -----------------start****stop-- 0xffffffff
while (ccount >= start && ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
}
}
else {
// stop did overflow, so only loop while outside of stop and start:
// 0x00000000 **stop-------------------start** 0xffffffff
while (ccount >= start || ccount < stop) {
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
}
}
}

View file

@ -37,7 +37,7 @@ Servo::Servo() {
int8_t Servo::attach(const int inPin) {
if (channel >= CHANNEL_MAX_NUM) return -1;
if (pin > 0) pin = inPin;
if (inPin > 0) pin = inPin;
ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth
ledcAttachPin(pin, channel);

View file

@ -72,6 +72,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif

View file

@ -177,7 +177,7 @@ int i2s_init() {
*
* fwclk = fbclk / 32
*
* for fwclk = 250kHz (4uS pulse time)
* for fwclk = 250kHz (4µS pulse time)
* N = 10
* M = 20
*/

View file

@ -28,3 +28,11 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif
#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
#error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
#endif

View file

@ -21,7 +21,7 @@
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(OTASUPPORT)
#if BOTH(WIFISUPPORT, OTASUPPORT)
#include <WiFi.h>
#include <ESPmDNS.h>
@ -67,6 +67,5 @@ void OTA_handle() {
ArduinoOTA.handle();
}
#endif // OTASUPPORT
#endif // WIFISUPPORT && OTASUPPORT
#endif // ARDUINO_ARCH_ESP32

View file

@ -24,7 +24,7 @@
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(WEBSUPPORT)
#if BOTH(WIFISUPPORT, WEBSUPPORT)
#include "../../core/serial.h"
@ -40,5 +40,5 @@ void spiffs_init() {
SERIAL_ERROR_MSG("SPIFFS mount failed");
}
#endif // WEBSUPPORT
#endif // WIFISUPPORT && WEBSUPPORT
#endif // ARDUINO_ARCH_ESP32

View file

@ -47,7 +47,7 @@ typedef uint64_t hal_timer_t;
#if ENABLED(I2S_STEPPER_STREAM)
#define STEPPER_TIMER_PRESCALE 1
#define STEPPER_TIMER_RATE 250000 // 250khz, 4us pulses of i2s word clock
#define STEPPER_TIMER_RATE 250000 // 250khz, 4µs pulses of i2s word clock
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
#else
#define STEPPER_TIMER_PRESCALE 40

View file

@ -22,13 +22,12 @@
#ifdef ARDUINO_ARCH_ESP32
#include <SPIFFS.h>
#undef DISABLED // esp32-hal-gpio.h
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(WEBSUPPORT)
#if BOTH(WIFISUPPORT, WEBSUPPORT)
#undef DISABLED // esp32-hal-gpio.h
#include <SPIFFS.h>
#include "wifi.h"
AsyncEventSource events("/events"); // event source (Server-Sent events)
@ -43,5 +42,5 @@ void web_init() {
server.onNotFound(onNotFound);
}
#endif // WEBSUPPORT
#endif // WIFISUPPORT && WEBSUPPORT
#endif // ARDUINO_ARCH_ESP32

View file

@ -55,7 +55,7 @@ void HAL_adc_init() {
}
void HAL_adc_enable_channel(int ch) {
void HAL_adc_enable_channel(const uint8_t ch) {
}

View file

@ -87,15 +87,15 @@ int freeMemory();
#pragma GCC diagnostic pop
// ADC
#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
#define HAL_ADC_RESOLUTION 10
#define HAL_READ_ADC() HAL_adc_get_result()
#define HAL_ADC_READY() true
void HAL_adc_init();
void HAL_adc_enable_channel(int pin);
void HAL_adc_start_conversion(const uint8_t adc_pin);
void HAL_adc_enable_channel(const uint8_t ch);
void HAL_adc_start_conversion(const uint8_t ch);
uint16_t HAL_adc_get_result();
// Reset source

View file

@ -33,3 +33,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -61,10 +61,6 @@ extern "C" volatile uint32_t _millis;
#define ST7920_DELAY_3 DELAY_NS(750)
#endif
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3"
#endif
#if SERIAL_PORT == -1
#define MYSERIAL0 UsbSerial
#elif SERIAL_PORT == 0
@ -75,16 +71,14 @@ extern "C" volatile uint32_t _millis;
#define MYSERIAL0 MSerial2
#elif SERIAL_PORT == 3
#define MYSERIAL0 MSerial3
#else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3"
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif
#define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 UsbSerial
#elif SERIAL_PORT_2 == 0
#define MYSERIAL1 MSerial
@ -94,11 +88,34 @@ extern "C" volatile uint32_t _millis;
#define MYSERIAL1 MSerial2
#elif SERIAL_PORT_2 == 3
#define MYSERIAL1 MSerial3
#else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL MSerial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
//
// Interrupts
//

View file

@ -93,7 +93,7 @@ void setup_endstop_interrupts() {
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
#if !LPC1768_PIN_INTERRUPT_M(Z3_MAX_PIN)
#error "Z3_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(Z3_MAX_PIN);
@ -104,6 +104,18 @@ void setup_endstop_interrupts() {
#endif
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
#if !LPC1768_PIN_INTERRUPT_M(Z4_MAX_PIN)
#error "Z4_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
#if !LPC1768_PIN_INTERRUPT_M(Z4_MIN_PIN)
#error "Z4_MIN_PIN is not INTERRUPT-capable."
#endif
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
#if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
#error "Z_MIN_PROBE_PIN is not INTERRUPT-capable."

View file

@ -46,6 +46,10 @@
#error "TEMP_4_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_5)
#error "TEMP_5_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_6)
#error "TEMP_6_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_7)
#error "TEMP_7_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#endif
#undef _OLD_TEMP_PIN

View file

@ -20,8 +20,10 @@
*
*/
// adapted from I2C/master/master.c example
// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
/**
* digipot_mcp4451_I2C_routines.c
* Adapted from https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
*/
#ifdef TARGET_LPC1768
@ -29,12 +31,12 @@
#if MB(MKS_SBASE)
#include "digipot_mcp4451_I2C_routines.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "digipot_mcp4451_I2C_routines.h"
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to
// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
@ -60,7 +62,6 @@ static void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) {
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC;
}
PINSEL_CFG_Type PinCfg;
I2C_M_SETUP_Type transferMCfg;
#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
@ -89,41 +90,6 @@ uint8_t digipot_mcp4451_start(uint8_t sla) { // send slave address and write bi
return 1;
}
void digipot_mcp4451_init() {
/**
* Init I2C pin connect
*/
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
#if USEDI2CDEV_M == 0
PinCfg.Funcnum = 1;
PinCfg.Pinnum = 27;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA0 / D57 AUX-1
PinCfg.Pinnum = 28;
PINSEL_ConfigPin(&PinCfg); // SCL0 / D58 AUX-1
#elif USEDI2CDEV_M == 1
PinCfg.Funcnum = 3;
PinCfg.Pinnum = 0;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA1 / D20 SCA
PinCfg.Pinnum = 1;
PINSEL_ConfigPin(&PinCfg); // SCL1 / D21 SCL
#elif USEDI2CDEV_M == 2
PinCfg.Funcnum = 2;
PinCfg.Pinnum = 10;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA2 / D38 X_ENABLE_PIN
PinCfg.Pinnum = 11;
PINSEL_ConfigPin(&PinCfg); // SCL2 / D55 X_DIR_PIN
#endif
// Initialize I2C peripheral
I2C_Init(I2CDEV_M, 400000); // hardwired to 400KHz bit rate, 100KHz is the other option
// Enable Master I2C operation
I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
}
uint8_t digipot_mcp4451_send_byte(uint8_t data) {
LPC_I2C1->I2DAT = data & I2C_I2DAT_BITMASK; // transmit data
LPC_I2C1->I2CONSET = I2C_I2CONSET_AA;

View file

@ -21,20 +21,10 @@
*/
#pragma once
// adapted from I2C/master/master.c example
// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
#define USEDI2CDEV_M 1 // use I2C1 controller
#if USEDI2CDEV_M == 0
#define I2CDEV_M LPC_I2C0
#elif USEDI2CDEV_M == 1
#define I2CDEV_M LPC_I2C1
#elif USEDI2CDEV_M == 2
#define I2CDEV_M LPC_I2C2
#else
#error "Master I2C device not defined!"
#endif
/**
* digipot_mcp4451_I2C_routines.h
* Adapted from https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
*/
#ifdef __cplusplus
extern "C" {
@ -43,9 +33,9 @@
#include <lpc17xx_i2c.h>
#include <lpc17xx_pinsel.h>
#include <lpc17xx_libcfg_default.h>
#include "i2c_util.h"
uint8_t digipot_mcp4451_start(uint8_t sla);
void digipot_mcp4451_init();
uint8_t digipot_mcp4451_send_byte(uint8_t data);
#ifdef __cplusplus

View file

@ -0,0 +1,70 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* HAL_LPC1768/include/i2c_util.c
*/
#ifdef TARGET_LPC1768
#include "i2c_util.h"
#define U8G_I2C_OPT_FAST 16 // from u8g.h
#ifdef __cplusplus
extern "C" {
#endif
void configure_i2c(const uint8_t clock_option) {
/**
* Init I2C pin connect
*/
PINSEL_CFG_Type PinCfg;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Portnum = 0;
#if I2C_MASTER_ID == 0
PinCfg.Funcnum = 1;
PinCfg.Pinnum = 27; // SDA0 / D57 AUX-1 ... SCL0 / D58 AUX-1
#elif I2C_MASTER_ID == 1
PinCfg.Funcnum = 3;
PinCfg.Pinnum = 0; // SDA1 / D20 SCA ... SCL1 / D21 SCL
#elif I2C_MASTER_ID == 2
PinCfg.Funcnum = 2;
PinCfg.Pinnum = 10; // SDA2 / D38 X_ENABLE_PIN ... SCL2 / D55 X_DIR_PIN
#endif
PINSEL_ConfigPin(&PinCfg);
PinCfg.Pinnum += 1;
PINSEL_ConfigPin(&PinCfg);
// Initialize I2C peripheral
I2C_Init(I2CDEV_M, (clock_option & U8G_I2C_OPT_FAST) ? 400000: 100000); // LCD data rates
// Enable Master I2C operation
I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
}
#ifdef __cplusplus
}
#endif
#endif // TARGET_LPC1768

View file

@ -0,0 +1,56 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* HAL_LPC1768/include/i2c_util.h
*/
#include "../../../inc/MarlinConfigPre.h"
#ifndef I2C_MASTER_ID
#define I2C_MASTER_ID 1
#endif
#if I2C_MASTER_ID == 0
#define I2CDEV_M LPC_I2C0
#elif I2C_MASTER_ID == 1
#define I2CDEV_M LPC_I2C1
#elif I2C_MASTER_ID == 2
#define I2CDEV_M LPC_I2C2
#else
#error "Master I2C device not defined!"
#endif
#include <lpc17xx_i2c.h>
#include <lpc17xx_pinsel.h>
#include <lpc17xx_libcfg_default.h>
#ifdef __cplusplus
extern "C" {
#endif
void configure_i2c(const uint8_t clock_option);
#ifdef __cplusplus
}
#endif

View file

@ -25,19 +25,15 @@
#ifdef TARGET_LPC1768
#include "../include/i2c_util.h"
#include "../../../core/millis_t.h"
extern int millis();
#ifdef __cplusplus
extern "C" {
#endif
#include <lpc17xx_i2c.h>
#include <lpc17xx_pinsel.h>
#include <lpc17xx_libcfg_default.h>
#include "../../../core/millis_t.h"
//////////////////////////////////////////////////////////////////////////////////////
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to
@ -67,30 +63,16 @@ static void _I2C_Stop (LPC_I2C_TypeDef *I2Cx) {
//////////////////////////////////////////////////////////////////////////////////////
#define U8G_I2C_OPT_FAST 16 // from u8g.h
#define USEDI2CDEV_M 1
#define I2CDEV_S_ADDR 0x78 // from SSD1306 //actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write
#define BUFFER_SIZE 0x1 // only do single byte transfers with LCDs
#if (USEDI2CDEV_M == 0)
#define I2CDEV_M LPC_I2C0
#elif (USEDI2CDEV_M == 1)
#define I2CDEV_M LPC_I2C1
#elif (USEDI2CDEV_M == 2)
#define I2CDEV_M LPC_I2C2
#else
#error "Master I2C device not defined!"
#endif
PINSEL_CFG_Type PinCfg;
I2C_M_SETUP_Type transferMCfg;
#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
uint8_t u8g_i2c_start(uint8_t sla) { // send slave address and write bit
// Send slave address and write bit
uint8_t u8g_i2c_start(const uint8_t sla) {
// Sometimes TX data ACK or NAK status is returned. That mean the start state didn't
// happen which means only the value of the slave address was send. Keep looping until
// the slave address and write bit are actually sent.
@ -114,44 +96,9 @@ uint8_t u8g_i2c_start(uint8_t sla) { // send slave address and write bit
return 1;
}
void u8g_i2c_init(uint8_t clock_option) {
/**
* Init I2C pin connect
*/
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
#if ((USEDI2CDEV_M == 0))
PinCfg.Funcnum = 1;
PinCfg.Pinnum = 27;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA0 / D57 AUX-1
PinCfg.Pinnum = 28;
PINSEL_ConfigPin(&PinCfg); // SCL0 / D58 AUX-1
#endif
#if ((USEDI2CDEV_M == 1))
PinCfg.Funcnum = 3;
PinCfg.Pinnum = 0;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA1 / D20 SCA
PinCfg.Pinnum = 1;
PINSEL_ConfigPin(&PinCfg); // SCL1 / D21 SCL
#endif
#if ((USEDI2CDEV_M == 2))
PinCfg.Funcnum = 2;
PinCfg.Pinnum = 10;
PinCfg.Portnum = 0;
PINSEL_ConfigPin(&PinCfg); // SDA2 / D38 X_ENABLE_PIN
PinCfg.Pinnum = 11;
PINSEL_ConfigPin(&PinCfg); // SCL2 / D55 X_DIR_PIN
#endif
// Initialize I2C peripheral
I2C_Init(I2CDEV_M, (clock_option & U8G_I2C_OPT_FAST) ? 400000: 100000); // LCD data rates
// Enable Master I2C operation
I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
u8g_i2c_start(0); // send slave address and write bit
void u8g_i2c_init(const uint8_t clock_option) {
configure_i2c(clock_option);
u8g_i2c_start(0); // Send slave address and write bit
}
uint8_t u8g_i2c_send_byte(uint8_t data) {

View file

@ -21,8 +21,8 @@
*/
#pragma once
void u8g_i2c_init(uint8_t options);
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
void u8g_i2c_init(const uint8_t clock_options);
//uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
uint8_t u8g_i2c_start(uint8_t sla);
uint8_t u8g_i2c_send_byte(uint8_t data);
void u8g_i2c_stop();

View file

@ -26,8 +26,8 @@
*
* These are based on the LPC1768 routines.
*
* Couldn't just call exact copies because the overhead resulted in the
* one microsecond delay being about 4uS.
* Couldn't just call exact copies because the overhead
* results in a one microsecond delay taking about 4µS.
*/
#ifdef __cplusplus

View file

@ -86,8 +86,6 @@
#define I2C_CMD_MODE 0x000
#define I2C_DATA_MODE 0x040
//#define U8G_I2C_OPT_FAST 16
uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
/* are we requested to set the a0 state? */
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;

View file

@ -1,254 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Based on U8G2 code - u8x8_byte.c
*
* Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
*
* Copyright (c) 2016, olikraus@gmail.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Software i2c,
* ignores ACK response (which is anyway not provided by some displays)
* also does not allow reading from the device
*/
#ifdef TARGET_LPC1768
#include "../../inc/MarlinConfigPre.h"
#if HAS_GRAPHICAL_LCD
#include <U8glib.h>
//void pinMode(int16_t pin, uint8_t mode);
//void digitalWrite(int16_t pin, uint8_t pin_status);
#define I2C_SLA (0x3C*2)
//#define I2C_CMD_MODE 0x080
#define I2C_CMD_MODE 0x000
#define I2C_DATA_MODE 0x040
//static uint8_t I2C_speed; // 3 - 400KHz, 13 - 100KHz
//#define SPEED_400KHz 3
//#define SPEED_100KHz 13
// #define U8G_I2C_OPT_FAST 16
uint8_t SCL_pin_HAL_LPC1768_sw_I2C, SCL_port_HAL_LPC1768_sw_I2C, SDA_pin_HAL_LPC1768_sw_I2C, SDA_port_HAL_LPC1768_sw_I2C;
#define SPI_SPEED 2 //20: 200KHz 5:750KHz 2:3-4MHz
uint8_t u8g_i2c_send_byte_sw(uint8_t data) {
for (uint8_t i = 0; i < 9; i++) { // 1 extra bit for the ack/nak
if (val & 0x80)
for (uint8_t j = 0; j < SPI_SPEED; j++) {
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
}
else
for (uint8_t j = 0; j < SPI_SPEED; j++) {
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
}
for (uint8_t j = 0; j < SPI_SPEED; j++) {
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
}
for (uint8_t j = 0; j < SPI_SPEED; j++) {
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
}
val <<= 1;
}
return 1;
}
uint8_t u8g_i2c_start_sw(uint8_t sla) { // assert start condition and then send slave address with write bit
/* send the start condition, both lines go from 1 to 0 */
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
DELAY_US(2);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
DELAY_US(2);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
DELAY_US(2);
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
DELAY_US(2);
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
u8g_i2c_send_byte_sw(I2C_SLA); // send slave address with write bit
}
void u8g_i2c_stop_sw() { }
void u8g_i2c_init_sw(uint8_t clock_option) { u8g_i2c_start(0); } // send slave address and write bit
uint8_t u8g_com_ssd_I2C_start_sequence_sw(u8g_t *u8g) {
/* are we requested to set the a0 state? */
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
/* setup bus, might be a repeated start */
if (u8g_i2c_start(I2C_SLA) == 0) return 0;
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
}
else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0) return 0;
u8g->pin_list[U8G_PI_SET_A0] = 0;
return 1;
}
uint8_t u8g_com_HAL_LPC1768_ssd_sw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
switch (msg) {
case U8G_COM_MSG_INIT:
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
SCL_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SCL]);
SCL_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SCL]);
SDA_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SDA]);
SDA_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SDA]);
// As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
#define OUTPUT 0x1
u8g_SetPIOutput(u8g, U8G_PI_SCL);
u8g_SetPIOutput(u8g, U8G_PI_SDA);
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS]) u8g_SetPIOutput(u8g, U8G_PI_CS);
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_A0]) u8g_SetPIOutput(u8g, U8G_PI_A0);
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET);
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
//u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
//u8g->pin_list[U8G_PI_A0_STATE] = 0; /* initial RS state: unknown mode */
u8g_i2c_init_sw(u8g->pin_list[U8G_PI_I2C_OPTION]);
u8g_com_ssd_I2C_start_sequence_sw(u8g);
break;
case U8G_COM_MSG_STOP: break;
case U8G_COM_MSG_RESET: break;
case U8G_COM_MSG_CHIP_SELECT:
u8g->pin_list[U8G_PI_A0_STATE] = 0;
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
if (arg_val == 0) {
/* disable chip, send stop condition */
u8g_i2c_stop_sw();
}
else {
/* enable, do nothing: any byte writing will trigger the i2c start */
}
break;
case U8G_COM_MSG_WRITE_BYTE:
//u8g->pin_list[U8G_PI_SET_A0] = 1;
//if (u8g_com_arduino_ssd_start_sequence(u8g) == 0)
// return u8g_i2c_stop(), 0;
if (u8g_i2c_send_byte_sw(arg_val) == 0)
return u8g_i2c_stop_sw(), 0;
// u8g_i2c_stop();
break;
case U8G_COM_MSG_WRITE_SEQ: {
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
return u8g_i2c_stop_sw(), 0;
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
if (u8g_i2c_send_byte_sw(*ptr++) == 0)
return u8g_i2c_stop_sw(), 0;
arg_val--;
}
}
// u8g_i2c_stop();
break;
case U8G_COM_MSG_WRITE_SEQ_P: {
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
return u8g_i2c_stop_sw(), 0;
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
if (u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0) return 0;
ptr++;
arg_val--;
}
}
// u8g_i2c_stop();
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
u8g_i2c_start_sw(0); // send slave address and write bit
u8g_i2c_send_byte_sw(arg_val ? 0x40 : 0x80); // Write to ? Graphics DRAM mode : Command mode
break;
}
return 1;
}
#endif // HAS_GRAPHICAL_LCD
#endif // TARGET_LPC1768

View file

@ -9,7 +9,9 @@ target_filename = "FIRMWARE.CUR"
target_drive = "REARM"
import os
import getpass
import platform
current_OS = platform.system()
Import("env")
@ -77,28 +79,26 @@ try:
upload_disk = 'Disk not found'
target_file_found = False
target_drive_found = False
medias = os.listdir('/media') #
for media in medias:
drives = os.listdir('/media/' + media) #
if target_drive in drives and target_file_found == False: # set upload if not found target file yet
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
if target_drive in drives: # If target drive is found, use it.
target_drive_found = True
upload_disk = '/media/' + media + '/' + target_drive + '/'
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
else:
for drive in drives:
try:
files = os.listdir('/media/' + media + '/' + drive)
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
except:
continue
else:
if target_filename in files:
if target_file_found == False:
upload_disk = '/media/' + media + '/' + drive + '/'
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
target_file_found = True
break
#
# set upload_port to drive if found
#
if target_file_found == True or target_drive_found == True:
if target_file_found or target_drive_found:
env.Replace(
UPLOAD_FLAGS="-P$UPLOAD_PORT",
UPLOAD_PORT=upload_disk

View file

@ -68,5 +68,4 @@ bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); }
void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); }
#endif // USE_WATCHDOG
#endif // TARGET_LPC1768

View file

@ -59,6 +59,21 @@
#else
#define GET_TEMP_5_ADC() -1
#endif
#if HAS_TEMP_ADC_6
#define GET_TEMP_6_ADC() PIN_TO_ADC(TEMP_6_PIN)
#else
#define GET_TEMP_6_ADC() -1
#endif
#if HAS_TEMP_ADC_7
#define GET_TEMP_7_ADC() PIN_TO_ADC(TEMP_7_PIN)
#else
#define GET_TEMP_7_ADC() -1
#endif
#if HAS_TEMP_PROBE
#define GET_PROBE_ADC() PIN_TO_ADC(TEMP_PROBE_PIN)
#else
#define GET_PROBE_ADC() -1
#endif
#if HAS_TEMP_ADC_BED
#define GET_BED_ADC() PIN_TO_ADC(TEMP_BED_PIN)
#else
@ -80,12 +95,15 @@
#define GET_BUTTONS_ADC() -1
#endif
#define IS_ADC_REQUIRED(n) (GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n \
|| GET_TEMP_3_ADC() == n || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n \
#define IS_ADC_REQUIRED(n) ( \
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
|| GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \
|| GET_PROBE_ADC() == n \
|| GET_BED_ADC() == n \
|| GET_CHAMBER_ADC() == n \
|| GET_FILAMENT_WIDTH_ADC() == n \
|| GET_BUTTONS_ADC() == n)
|| GET_BUTTONS_ADC() == n \
)
#define ADC0_IS_REQUIRED IS_ADC_REQUIRED(0)
#define ADC1_IS_REQUIRED IS_ADC_REQUIRED(1)
@ -145,6 +163,15 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 0
TEMP_5_PIN,
#endif
#if GET_TEMP_6_ADC() == 0
TEMP_6_PIN,
#endif
#if GET_TEMP_7_ADC() == 0
TEMP_7_PIN,
#endif
#if GET_PROBE_ADC() == 0
TEMP_PROBE_PIN,
#endif
#if GET_BED_ADC() == 0
TEMP_BED_PIN,
#endif
@ -176,6 +203,15 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 1
TEMP_5_PIN,
#endif
#if GET_TEMP_6_ADC() == 1
TEMP_6_PIN,
#endif
#if GET_TEMP_7_ADC() == 1
TEMP_7_PIN,
#endif
#if GET_PROBE_ADC() == 1
TEMP_PROBE_PIN,
#endif
#if GET_BED_ADC() == 1
TEMP_BED_PIN,
#endif
@ -215,6 +251,15 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_5_PIN) },
#endif
#if GET_TEMP_6_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_6_PIN) },
#endif
#if GET_TEMP_7_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif
#if GET_PROBE_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_BED_ADC() == 0
{ PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
#endif
@ -255,6 +300,15 @@ uint16_t HAL_adc_result;
#if GET_TEMP_5_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_5_PIN) },
#endif
#if GET_TEMP_6_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_6_PIN) },
#endif
#if GET_TEMP_7_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_7_PIN) },
#endif
#if GET_PROBE_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
#endif
#if GET_BED_ADC() == 1
{ PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
#endif
@ -471,8 +525,4 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = 0xFFFF;
}
uint16_t HAL_adc_get_result() {
return HAL_adc_result;
}
#endif // __SAMD51__

View file

@ -33,11 +33,9 @@
#include "MarlinSerial_AGCM4.h"
// Serial ports
#if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from -1 to 3"
#endif
// MYSERIAL0 required before MarlinSerial includes!
#if SERIAL_PORT == -1
#define MYSERIAL0 Serial
#elif SERIAL_PORT == 0
@ -46,18 +44,16 @@
#define MYSERIAL0 Serial2
#elif SERIAL_PORT == 2
#define MYSERIAL0 Serial3
#else
#elif SERIAL_PORT == 3
#define MYSERIAL0 Serial4
#else
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from -1 to 3"
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif
#define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 Serial
#elif SERIAL_PORT_2 == 0
#define MYSERIAL1 Serial1
@ -65,13 +61,36 @@
#define MYSERIAL1 Serial2
#elif SERIAL_PORT_2 == 2
#define MYSERIAL1 Serial3
#else
#elif SERIAL_PORT_2 == 3
#define MYSERIAL1 Serial4
#else
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial3
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial4
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
#endif // ADAFRUIT_GRAND_CENTRAL_M4
typedef int8_t pin_t;
@ -116,7 +135,7 @@ void HAL_adc_init();
#define HAL_ADC_READY() true
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();
inline uint16_t HAL_adc_get_result() { return HAL_adc_result; }
//
// Pin Map

View file

@ -98,6 +98,16 @@
#else
#define MATCH_Z3_MIN_EILINE(P) false
#endif
#if HAS_Z4_MAX
#define MATCH_Z4_MAX_EILINE(P) MATCH_EILINE(P, Z4_MAX_PIN)
#else
#define MATCH_Z4_MAX_EILINE(P) false
#endif
#if HAS_Z4_MIN
#define MATCH_Z4_MIN_EILINE(P) MATCH_EILINE(P, Z4_MIN_PIN)
#else
#define MATCH_Z4_MIN_EILINE(P) false
#endif
#if HAS_Z_MIN_PROBE_PIN
#define MATCH_Z_MIN_PROBE_EILINE(P) MATCH_EILINE(P, Z_MIN_PROBE_PIN)
#else
@ -109,6 +119,7 @@
&& !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
&& !MATCH_Z_MIN_PROBE_EILINE(P))
// One ISR for all EXT-Interrupts
@ -117,67 +128,79 @@ void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() {
#if HAS_X_MAX
#if !AVAILABLE_EILINE(X_MAX_PIN)
static_assert(false, "X_MAX_PIN has no EXTINT line available.");
#error "X_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_X_MIN
#if !AVAILABLE_EILINE(X_MIN_PIN)
static_assert(false, "X_MIN_PIN has no EXTINT line available.");
#error "X_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Y_MAX
#if !AVAILABLE_EILINE(Y_MAX_PIN)
static_assert(false, "Y_MAX_PIN has no EXTINT line available.");
#error "Y_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Y_MIN
#if !AVAILABLE_EILINE(Y_MIN_PIN)
static_assert(false, "Y_MIN_PIN has no EXTINT line available.");
#error "Y_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MAX
#if !AVAILABLE_EILINE(Z_MAX_PIN)
static_assert(false, "Z_MAX_PIN has no EXTINT line available.");
#error "Z_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN
#if !AVAILABLE_EILINE(Z_MIN_PIN)
static_assert(false, "Z_MIN_PIN has no EXTINT line available.");
#error "Z_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z2_MAX
#if !AVAILABLE_EILINE(Z2_MAX_PIN)
static_assert(false, "Z2_MAX_PIN has no EXTINT line available.");
#error "Z2_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z2_MIN
#if !AVAILABLE_EILINE(Z2_MIN_PIN)
static_assert(false, "Z2_MIN_PIN has no EXTINT line available.");
#error "Z2_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MAX
#if !AVAILABLE_EILINE(Z3_MAX_PIN)
static_assert(false, "Z3_MAX_PIN has no EXTINT line available.");
#error "Z3_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MIN
#if !AVAILABLE_EILINE(Z3_MIN_PIN)
static_assert(false, "Z3_MIN_PIN has no EXTINT line available.");
#error "Z3_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
#if !AVAILABLE_EILINE(Z4_MAX_PIN)
#error "Z4_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
#if !AVAILABLE_EILINE(Z4_MIN_PIN)
#error "Z4_MIN_PIN has no EXTINT line available."
#endif
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
#if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN)
static_assert(false, "Z_MIN_PROBE_PIN has no EXTINT line available.");
#error "Z_MIN_PROBE_PIN has no EXTINT line available."
#endif
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif

View file

@ -46,3 +46,7 @@
#if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM)
#warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator"
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -28,13 +28,7 @@
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"
#if (__cplusplus == 201703L) && defined(__has_include)
#define HAS_SWSERIAL __has_include(<SoftwareSerial.h>)
#else
#define HAS_SWSERIAL HAS_TMC220x
#endif
#if HAS_SWSERIAL
#if TMC_HAS_SW_SERIAL
#include "SoftwareSerial.h"
#endif
@ -93,7 +87,7 @@ void HAL_init() {
while (!LL_PWR_IsActiveFlag_BRR());
#endif // EEPROM_EMULATED_SRAM
#if HAS_SWSERIAL
#if TMC_HAS_SW_SERIAL
SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
#endif
}
@ -101,11 +95,27 @@ void HAL_init() {
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
uint8_t HAL_get_reset_source() {
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
return 0;
return
#ifdef RCC_FLAG_IWDGRST // Some sources may not exist...
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG :
#endif
#ifdef RCC_FLAG_IWDG1RST
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDG1RST) ? RST_WATCHDOG :
#endif
#ifdef RCC_FLAG_IWDG2RST
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDG2RST) ? RST_WATCHDOG :
#endif
#ifdef RCC_FLAG_SFTRST
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) ? RST_SOFTWARE :
#endif
#ifdef RCC_FLAG_PINRST
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) ? RST_EXTERNAL :
#endif
#ifdef RCC_FLAG_PORRST
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) ? RST_POWER_ON :
#endif
0
;
}
void _delay_ms(const int delay_ms) { delay(delay_ms); }

View file

@ -44,13 +44,8 @@
// ------------------------
#if SERIAL_PORT == 0
#error "Serial port 0 does not exist"
#endif
#if !WITHIN(SERIAL_PORT, -1, 6)
#error "SERIAL_PORT must be from -1 to 6"
#endif
#if SERIAL_PORT == -1
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#define MYSERIAL0 SerialUSB
#elif SERIAL_PORT == 1
#define MYSERIAL0 Serial1
@ -64,20 +59,17 @@
#define MYSERIAL0 Serial5
#elif SERIAL_PORT == 6
#define MYSERIAL0 Serial6
#else
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == 0
#error "Serial port 0 does not exist"
#endif
#if !WITHIN(SERIAL_PORT_2, -1, 6)
#error "SERIAL_PORT_2 must be from -1 to 6"
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif
#define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1
#if SERIAL_PORT_2 == 0
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 SerialUSB
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 Serial1
@ -91,11 +83,41 @@
#define MYSERIAL1 Serial5
#elif SERIAL_PORT_2 == 6
#define MYSERIAL1 Serial6
#else
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
#endif
#else
#define NUM_SERIAL 1
#endif
#if HAS_DGUS_LCD
#if DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL SerialUSB
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL Serial3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL Serial4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL Serial5
#elif DGUS_SERIAL_PORT == 6
#define DGUS_SERIAL Serial6
#else
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
#endif
#include "timers.h"
/**

View file

@ -37,10 +37,82 @@ static SPISettings spiConfig;
// ------------------------
#if ENABLED(SOFTWARE_SPI)
// ------------------------
// Software SPI
// ------------------------
#error "Software SPI not supported for STM32. Use Hardware SPI."
#include "../shared/Delay.h"
void spiBegin(void) {
OUT_WRITE(SS_PIN, HIGH);
OUT_WRITE(SCK_PIN, HIGH);
SET_INPUT(MISO_PIN);
OUT_WRITE(MOSI_PIN, HIGH);
}
static uint16_t delay_STM32_soft_spi;
void spiInit(uint8_t spiRate) {
// Use datarates Marlin uses
switch (spiRate) {
case SPI_FULL_SPEED: delay_STM32_soft_spi = 125; break; // desired: 8,000,000 actual: ~1.1M
case SPI_HALF_SPEED: delay_STM32_soft_spi = 125; break; // desired: 4,000,000 actual: ~1.1M
case SPI_QUARTER_SPEED:delay_STM32_soft_spi = 250; break; // desired: 2,000,000 actual: ~890K
case SPI_EIGHTH_SPEED: delay_STM32_soft_spi = 500; break; // desired: 1,000,000 actual: ~590K
case SPI_SPEED_5: delay_STM32_soft_spi = 1000; break; // desired: 500,000 actual: ~360K
case SPI_SPEED_6: delay_STM32_soft_spi = 2000; break; // desired: 250,000 actual: ~210K
default: delay_STM32_soft_spi = 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_STM32_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
for (uint8_t bits = 8; bits--;) {
WRITE(SCK_PIN, LOW);
WRITE(MOSI_PIN, b & 0x80);
DELAY_NS(delay_STM32_soft_spi);
WRITE(SCK_PIN, HIGH);
DELAY_NS(delay_STM32_soft_spi);
b <<= 1; // little setup time
b |= (READ(MISO_PIN) != 0);
}
DELAY_NS(125);
return b;
}
// Soft SPI receive byte
uint8_t spiRec() {
DISABLE_ISRS(); // No interrupts during byte receive
const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF);
ENABLE_ISRS(); // 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) {
DISABLE_ISRS(); // No interrupts during byte send
HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received
ENABLE_ISRS(); // 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
@ -67,7 +139,7 @@ void spiBegin() {
OUT_WRITE(SS_PIN, HIGH);
}
/** Configure SPI for specified SPI speed */
// Configure SPI for specified SPI speed
void spiInit(uint8_t spiRate) {
// Use datarates Marlin uses
uint32_t clock;
@ -108,7 +180,7 @@ uint8_t spiRec() {
}
/**
* @brief Receives a number of bytes from the SPI port to a buffer
* @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.
@ -125,7 +197,7 @@ void spiRead(uint8_t* buf, uint16_t nbyte) {
}
/**
* @brief Sends a single byte on SPI port
* @brief Send a single byte on SPI port
*
* @param b Byte to send
*

View file

@ -58,6 +58,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif

View file

@ -33,7 +33,6 @@
#define hal_timer_t uint32_t
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
#ifdef STM32F0xx
#define HAL_TIMER_RATE (F_CPU) // frequency of timer peripherals
@ -58,18 +57,42 @@
#define TEMP_TIMER 2
#endif
#elif defined(STM32F4xx) || defined(STM32F7xx)
#elif defined(STM32F401xC) || defined(STM32F401xE)
#define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
#ifndef STEP_TIMER
#define STEP_TIMER 5
#define STEP_TIMER 9
#endif
#ifndef TEMP_TIMER
#define TEMP_TIMER 10
#endif
#elif defined(STM32F4xx)
#define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
#ifndef STEP_TIMER
#define STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8
#endif
#ifndef TEMP_TIMER
#define TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used.
#endif
#elif defined(STM32F7xx)
#define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
#ifndef STEP_TIMER
#define STEP_TIMER 6 // the RIGHT timer!
#endif
#ifndef TEMP_TIMER
#define TEMP_TIMER 14
#endif
#endif
#ifndef SWSERIAL_TIMER_IRQ_PRIO

View file

@ -118,6 +118,12 @@ const uint8_t adc_pins[] = {
#if HAS_TEMP_ADC_5
TEMP_5_PIN,
#endif
#if HAS_TEMP_ADC_6
TEMP_6_PIN,
#endif
#if HAS_TEMP_ADC_7
TEMP_7_PIN,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH_PIN,
#endif
@ -160,6 +166,12 @@ enum TEMP_PINS : char {
#if HAS_TEMP_ADC_5
TEMP_5,
#endif
#if HAS_TEMP_ADC_6
TEMP_6,
#endif
#if HAS_TEMP_ADC_7
TEMP_7,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH,
#endif
@ -346,6 +358,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
#if HAS_TEMP_ADC_5
case TEMP_5_PIN: pin_index = TEMP_5; break;
#endif
#if HAS_TEMP_ADC_6
case TEMP_6_PIN: pin_index = TEMP_6; break;
#endif
#if HAS_TEMP_ADC_7
case TEMP_7_PIN: pin_index = TEMP_7; break;
#endif
#if HAS_JOY_ADC_X
case JOY_X_PIN: pin_index = JOY_X; break;
#endif

View file

@ -78,13 +78,10 @@
#define MSerial5 Serial4
#endif
#if !WITHIN(SERIAL_PORT, -1, 5)
#error "SERIAL_PORT must be from -1 to 5"
#endif
#if SERIAL_PORT == -1
#if SERIAL_PORT == 0
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#define MYSERIAL0 UsbSerial
#elif SERIAL_PORT == 0
#error "Serial port 0 does not exist"
#elif SERIAL_PORT == 1
#define MYSERIAL0 MSerial1
#elif SERIAL_PORT == 2
@ -95,19 +92,17 @@
#define MYSERIAL0 MSerial4
#elif SERIAL_PORT == 5
#define MYSERIAL0 MSerial5
#else
#error "SERIAL_PORT must be from -1 to 5. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 5)
#error "SERIAL_PORT_2 must be from -1 to 5"
#if SERIAL_PORT_2 == 0
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif
#define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 UsbSerial
#elif SERIAL_PORT_2 == 0
#error "Serial port 0 does not exist"
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 MSerial1
#elif SERIAL_PORT_2 == 2
@ -118,11 +113,39 @@
#define MYSERIAL1 MSerial4
#elif SERIAL_PORT_2 == 5
#define MYSERIAL1 MSerial5
#else
#error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration."
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL
#if DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL MSerial4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL MSerial5
#else
#error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration."
#endif
#endif
// Set interrupt grouping for this MCU
void HAL_init();
#define HAL_IDLETASK 1

View file

@ -49,6 +49,7 @@
void LCD_IO_Init(uint8_t cs, uint8_t rs);
void LCD_IO_WriteData(uint16_t RegValue);
void LCD_IO_WriteReg(uint16_t Reg);
uint16_t LCD_IO_ReadData(uint16_t RegValue);
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
#ifdef LCD_USE_DMA_FSMC
void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
@ -79,8 +80,11 @@ uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
LCD_IO_Init(u8g->pin_list[U8G_PI_CS], u8g->pin_list[U8G_PI_A0]);
u8g_Delay(50);
if (arg_ptr)
*((uint32_t *)arg_ptr) = LCD_IO_ReadData(LCD_READ_ID, 3);
if (arg_ptr) {
*((uint32_t *)arg_ptr) = LCD_IO_ReadData(0x0000);
if (*((uint32_t *)arg_ptr) == 0)
*((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3);
}
isCommand = 0;
break;
@ -265,6 +269,13 @@ void LCD_IO_WriteReg(uint16_t Reg) {
__DSB();
}
uint16_t LCD_IO_ReadData(uint16_t RegValue) {
LCD->REG = RegValue;
__DSB();
return LCD->RAM;
}
uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
volatile uint32_t data;
LCD->REG = RegValue;

View file

@ -82,6 +82,12 @@ void setup_endstop_interrupts() {
#endif
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);

View file

@ -37,7 +37,7 @@
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if !defined(HAVE_SW_SERIAL) && HAS_TMC220x
#if !defined(HAVE_SW_SERIAL) && TMC_HAS_SW_SERIAL
#warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER."
#error "Missing SoftwareSerial implementation."
#endif

View file

@ -48,13 +48,8 @@
//extern HalSerial usb_serial;
#if defined(STM32F4) && SERIAL_PORT == 0
#error "Serial port 0 does not exist"
#endif
#if !WITHIN(SERIAL_PORT, -1, 6)
#error "SERIAL_PORT must be from -1 to 6"
#endif
#if SERIAL_PORT == -1
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#define MYSERIAL0 SerialUSB
#elif SERIAL_PORT == 1
#define MYSERIAL0 SerialUART1
@ -68,19 +63,16 @@
#define MYSERIAL0 SerialUART5
#elif SERIAL_PORT == 6
#define MYSERIAL0 SerialUART6
#else
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#ifdef SERIAL_PORT_2
#if defined(STM32F4) && SERIAL_PORT_2 == 0
#error "Serial port 0 does not exist"
#endif
#if !WITHIN(SERIAL_PORT_2, -1, 6)
#error "SERIAL_PORT_2 must be from -1 to 6"
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif
#define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 SerialUSB
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 SerialUART1
@ -94,11 +86,40 @@
#define MYSERIAL1 SerialUART5
#elif SERIAL_PORT_2 == 6
#define MYSERIAL1 SerialUART6
#else
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
#endif
#ifdef DGUS_SERIAL_PORT
#if defined(STM32F4) && DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL SerialUSB
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL SerialUART1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL SerialUART2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL SerialUART3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL SerialUART4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL SerialUART5
#elif DGUS_SERIAL_PORT == 6
#define DGUS_SERIAL SerialUART6
#else
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#endif
/**
* TODO: review this to return 1 for pins that are not analog input
*/

View file

@ -36,7 +36,7 @@
#include "TMC2660.h"
#include "../../../inc/MarlinConfig.h"
#include "../../../Marlin.h"
#include "../../../MarlinCore.h"
#include "../../../module/stepper/indirection.h"
#include "../../../module/printcounter.h"
#include "../../../libs/duration_t.h"

View file

@ -58,6 +58,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif

View file

@ -35,3 +35,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -32,3 +32,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -94,7 +94,7 @@ extern "C" {
}
void HAL_adc_start_conversion(const uint8_t adc_pin) {
uint16_t pin = pin2sc1a[adc_pin];
const uint16_t pin = pin2sc1a[adc_pin];
if (pin == 0xFF) {
// Digital only
HAL_adc_select = -1;

View file

@ -76,6 +76,12 @@ void setup_endstop_interrupts() {
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif

View file

@ -32,3 +32,7 @@
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

View file

@ -145,21 +145,7 @@
}
#undef nop
#elif defined(ESP32)
FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
unsigned long ccount, stop;
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
stop = ccount + x; // This can overflow
while (ccount < stop) { // This doesn't deal with overflows
__asm__ __volatile__ ( "rsr %0, ccount" : "=a" (ccount) );
}
}
#elif defined(__PLAT_LINUX__)
#elif defined(__PLAT_LINUX__) || defined(ESP32)
// specified inside platform

View file

@ -27,12 +27,12 @@
#include "../../inc/MarlinConfig.h"
#if HAS_DRIVER(L6470)
#if HAS_L64XX
#include "Delay.h"
#include "../../core/serial.h"
#include "../../libs/L6470/L6470_Marlin.h"
#include "../../libs/L64XX/L64XX_Marlin.h"
// Make sure GCC optimizes this file.
// Note that this line triggers a bug in GCC which is fixed by casting.
@ -40,7 +40,7 @@
#pragma GCC optimize (3)
// run at ~4Mhz
uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
for (uint8_t bits = 8; bits--;) {
WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80);
b <<= 1; // little setup time
@ -56,61 +56,26 @@ uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
return b;
}
uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
for (uint8_t bits = 8; bits--;) {
WRITE(L6470_CHAIN_SCK_PIN, LOW);
WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80);
DELAY_NS(125); // 10 cycles @ 84mhz
WRITE(L6470_CHAIN_SCK_PIN, HIGH);
DELAY_NS(125); // Need more delay for fast CPUs
b <<= 1; // little setup time
b |= (READ(L6470_CHAIN_MISO_PIN) != 0);
}
DELAY_NS(125); // 10 cycles @ 84mhz
return b;
}
/**
* The following are weak-linked and defined as do-nothing
* functions by the L6470-Arduino library. They must be
* defined by the client (Marlin) to provide an SPI interface.
* L64XX methods for SPI init and transfer
*/
uint8_t L6470_transfer(uint8_t data, int16_t ss_pin, const uint8_t chain_position) {
uint8_t data_out = 0;
// first device in chain has data sent last
extDigitalWrite(ss_pin, LOW);
for (uint8_t i = L6470::chain[0]; (i >= 1) && !spi_abort; i--) { // stop sending data if spi_abort is active
DISABLE_ISRS(); // disable interrupts during SPI transfer (can't allow partial command to chips)
uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP));
ENABLE_ISRS(); // enable interrupts
if (i == chain_position) data_out = temp;
}
extDigitalWrite(ss_pin, HIGH);
return data_out;
}
void L6470_transfer(uint8_t L6470_buf[], const uint8_t length) {
// first device in chain has data sent last
if (spi_active) { // interrupted SPI transfer so need to
WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650nS
DELAY_US(1);
}
WRITE(L6470_CHAIN_SS_PIN, LOW);
for (uint8_t i = length; i >= 1; i--)
L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i]));
WRITE(L6470_CHAIN_SS_PIN, HIGH);
}
void L6470_spi_init() {
void L64XX_Marlin::spi_init() {
OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH);
OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH);
OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
@ -123,6 +88,52 @@ void L6470_spi_init() {
OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
}
uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) {
// First device in chain has data sent last
extDigitalWrite(ss_pin, LOW);
DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
const uint8_t data_out = L6470_SpiTransfer_Mode_3(data);
ENABLE_ISRS(); // Enable interrupts
extDigitalWrite(ss_pin, HIGH);
return data_out;
}
uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) {
uint8_t data_out = 0;
// first device in chain has data sent last
extDigitalWrite(ss_pin, LOW);
for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted
DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP));
ENABLE_ISRS(); // Enable interrupts
if (i == chain_position) data_out = temp;
}
extDigitalWrite(ss_pin, HIGH);
return data_out;
}
/**
* Platform-supplied L6470 buffer transfer method
*/
void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) {
// First device in chain has its data sent last
if (spi_active) { // Interrupted SPI transfer so need to
WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650ns
DELAY_US(1);
}
WRITE(L6470_CHAIN_SS_PIN, LOW);
for (uint8_t i = length; i >= 1; i--)
L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i]));
WRITE(L6470_CHAIN_SS_PIN, HIGH);
}
#pragma GCC reset_options
#endif // HAS_DRIVER(L6470)
#endif // HAS_L64XX

View file

@ -28,6 +28,13 @@
#include "../../inc/MarlinConfigPre.h"
constexpr bool
#if HAS_DGUS_LCD
bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS = (false
#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
|| true
#endif
),
#endif
bSERIAL_XON_XOFF = (false
#if ENABLED(SERIAL_XON_XOFF)
|| true

View file

@ -164,7 +164,7 @@ typedef struct {
* link register (i.e. not a normal register) and the stack pointer value
* supplied.
*
* -If the program was compiled with -funwind-tables , it will use them to
* -If the program was compiled with -funwind-tables it will use them to
* perform the traceback. Otherwise, brute force will be employed
* -If the program was compiled with -mpoke-function-name, then you will
* get function names in the traceback. Otherwise, you will not.

View file

@ -1,381 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "inc/MarlinConfig.h"
#ifdef DEBUG_GCODE_PARSER
#include "gcode/parser.h"
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#if HAS_DRIVER(L6470)
#include "libs/L6470/L6470_Marlin.h"
extern uint8_t axis_known_position;
#endif
void stop();
void idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
bool no_stepper_sleep = false // pass true to keep steppers from disabling on timeout
#endif
);
void manage_inactivity(const bool ignore_stepper_queue=false);
//
// X, Y, Z Stepper enable / disable
//
#if AXIS_DRIVER_TYPE_X(L6470)
extern L6470 stepperX;
#define X_enable() NOOP
#define X_disable() stepperX.free()
#elif HAS_X_ENABLE
#define X_enable() X_ENABLE_WRITE( X_ENABLE_ON)
#define X_disable() X_ENABLE_WRITE(!X_ENABLE_ON)
#else
#define X_enable() NOOP
#define X_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_X2(L6470)
extern L6470 stepperX2;
#define X2_enable() NOOP
#define X2_disable() stepperX2.free()
#elif HAS_X2_ENABLE
#define X2_enable() X2_ENABLE_WRITE( X_ENABLE_ON)
#define X2_disable() X2_ENABLE_WRITE(!X_ENABLE_ON)
#else
#define X2_enable() NOOP
#define X2_disable() NOOP
#endif
#define enable_X() do{ X_enable(); X2_enable(); }while(0)
#define disable_X() do{ X_disable(); X2_disable(); CBI(axis_known_position, X_AXIS); }while(0)
#if AXIS_DRIVER_TYPE_Y(L6470)
extern L6470 stepperY;
#define Y_enable() NOOP
#define Y_disable() stepperY.free()
#elif HAS_Y_ENABLE
#define Y_enable() Y_ENABLE_WRITE( Y_ENABLE_ON)
#define Y_disable() Y_ENABLE_WRITE(!Y_ENABLE_ON)
#else
#define Y_enable() NOOP
#define Y_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_Y2(L6470)
extern L6470 stepperY2;
#define Y2_enable() NOOP
#define Y2_disable() stepperY2.free()
#elif HAS_Y2_ENABLE
#define Y2_enable() Y2_ENABLE_WRITE( Y_ENABLE_ON)
#define Y2_disable() Y2_ENABLE_WRITE(!Y_ENABLE_ON)
#else
#define Y2_enable() NOOP
#define Y2_disable() NOOP
#endif
#define enable_Y() do{ Y_enable(); Y2_enable(); }while(0)
#define disable_Y() do{ Y_disable(); Y2_disable(); CBI(axis_known_position, Y_AXIS); }while(0)
#if AXIS_DRIVER_TYPE_Z(L6470)
extern L6470 stepperZ;
#define Z_enable() NOOP
#define Z_disable() stepperZ.free()
#elif HAS_Z_ENABLE
#define Z_enable() Z_ENABLE_WRITE( Z_ENABLE_ON)
#define Z_disable() Z_ENABLE_WRITE(!Z_ENABLE_ON)
#else
#define Z_enable() NOOP
#define Z_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_Z2(L6470)
extern L6470 stepperZ2;
#define Z2_enable() NOOP
#define Z2_disable() stepperZ2.free()
#elif HAS_Z2_ENABLE
#define Z2_enable() Z2_ENABLE_WRITE( Z_ENABLE_ON)
#define Z2_disable() Z2_ENABLE_WRITE(!Z_ENABLE_ON)
#else
#define Z2_enable() NOOP
#define Z2_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_Z3(L6470)
extern L6470 stepperZ3;
#define Z3_enable() NOOP
#define Z3_disable() stepperZ3.free()
#elif HAS_Z3_ENABLE
#define Z3_enable() Z3_ENABLE_WRITE( Z_ENABLE_ON)
#define Z3_disable() Z3_ENABLE_WRITE(!Z_ENABLE_ON)
#else
#define Z3_enable() NOOP
#define Z3_disable() NOOP
#endif
#define enable_Z() do{ Z_enable(); Z2_enable(); Z3_enable(); }while(0)
#define disable_Z() do{ Z_disable(); Z2_disable(); Z3_disable(); CBI(axis_known_position, Z_AXIS); }while(0)
//
// Extruder Stepper enable / disable
//
// define the individual enables/disables
#if AXIS_DRIVER_TYPE_E0(L6470)
extern L6470 stepperE0;
#define E0_enable() NOOP
#define E0_disable() do{ stepperE0.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif HAS_E0_ENABLE
#define E0_enable() E0_ENABLE_WRITE( E_ENABLE_ON)
#define E0_disable() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E0_enable() NOOP
#define E0_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_E1(L6470)
extern L6470 stepperE1;
#define E1_enable() NOOP
#define E1_disable() do{ stepperE1.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif E_STEPPERS > 1 && HAS_E1_ENABLE
#define E1_enable() E1_ENABLE_WRITE( E_ENABLE_ON)
#define E1_disable() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E1_enable() NOOP
#define E1_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_E2(L6470)
extern L6470 stepperE2;
#define E2_enable() NOOP
#define E2_disable() do{ stepperE2.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif E_STEPPERS > 2 && HAS_E2_ENABLE
#define E2_enable() E2_ENABLE_WRITE( E_ENABLE_ON)
#define E2_disable() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E2_enable() NOOP
#define E2_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_E3(L6470)
extern L6470 stepperE3;
#define E3_enable() NOOP
#define E3_disable() do{ stepperE3.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif E_STEPPERS > 3 && HAS_E3_ENABLE
#define E3_enable() E3_ENABLE_WRITE( E_ENABLE_ON)
#define E3_disable() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E3_enable() NOOP
#define E3_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_E4(L6470)
extern L6470 stepperE4;
#define E4_enable() NOOP
#define E4_disable() do{ stepperE4.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif E_STEPPERS > 4 && HAS_E4_ENABLE
#define E4_enable() E4_ENABLE_WRITE( E_ENABLE_ON)
#define E4_disable() E4_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E4_enable() NOOP
#define E4_disable() NOOP
#endif
#if AXIS_DRIVER_TYPE_E5(L6470)
extern L6470 stepperE5;
#define E5_enable() NOOP
#define E5_disable() do{ stepperE5.free(); CBI(axis_known_position, E_AXIS); }while(0)
#elif E_STEPPERS > 5 && HAS_E5_ENABLE
#define E5_enable() E5_ENABLE_WRITE( E_ENABLE_ON)
#define E5_disable() E5_ENABLE_WRITE(!E_ENABLE_ON)
#else
#define E5_enable() NOOP
#define E5_disable() NOOP
#endif
#if ENABLED(MIXING_EXTRUDER)
/**
* Mixing steppers synchronize their enable (and direction) together
*/
#if MIXING_STEPPERS > 5
#define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); E5_enable(); }
#define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); E5_disable(); }
#elif MIXING_STEPPERS > 4
#define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); E4_enable(); }
#define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); }
#elif MIXING_STEPPERS > 3
#define enable_E0() { E0_enable(); E1_enable(); E2_enable(); E3_enable(); }
#define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); }
#elif MIXING_STEPPERS > 2
#define enable_E0() { E0_enable(); E1_enable(); E2_enable(); }
#define disable_E0() { E0_disable(); E1_disable(); E2_disable(); }
#else
#define enable_E0() { E0_enable(); E1_enable(); }
#define disable_E0() { E0_disable(); E1_disable(); }
#endif
#define enable_E1() NOOP
#define disable_E1() NOOP
#define enable_E2() NOOP
#define disable_E2() NOOP
#define enable_E3() NOOP
#define disable_E3() NOOP
#define enable_E4() NOOP
#define disable_E4() NOOP
#define enable_E5() NOOP
#define disable_E5() NOOP
#else // !MIXING_EXTRUDER
#if HAS_E0_ENABLE
#define enable_E0() E0_enable()
#define disable_E0() E0_disable()
#else
#define enable_E0() NOOP
#define disable_E0() NOOP
#endif
#if E_STEPPERS > 1 && HAS_E1_ENABLE
#define enable_E1() E1_enable()
#define disable_E1() E1_disable()
#else
#define enable_E1() NOOP
#define disable_E1() NOOP
#endif
#if E_STEPPERS > 2 && HAS_E2_ENABLE
#define enable_E2() E2_enable()
#define disable_E2() E2_disable()
#else
#define enable_E2() NOOP
#define disable_E2() NOOP
#endif
#if E_STEPPERS > 3 && HAS_E3_ENABLE
#define enable_E3() E3_enable()
#define disable_E3() E3_disable()
#else
#define enable_E3() NOOP
#define disable_E3() NOOP
#endif
#if E_STEPPERS > 4 && HAS_E4_ENABLE
#define enable_E4() E4_enable()
#define disable_E4() E4_disable()
#else
#define enable_E4() NOOP
#define disable_E4() NOOP
#endif
#if E_STEPPERS > 5 && HAS_E5_ENABLE
#define enable_E5() E5_enable()
#define disable_E5() E5_disable()
#else
#define enable_E5() NOOP
#define disable_E5() NOOP
#endif
#endif // !MIXING_EXTRUDER
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h"
extern TWIBus i2c;
#endif
#if ENABLED(G38_PROBE_TARGET)
extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type
extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed
#endif
/**
* The axis order in all axis related arrays is X, Y, Z, E
*/
void enable_e_steppers();
void enable_all_steppers();
void disable_e_stepper(const uint8_t e);
void disable_e_steppers();
void disable_all_steppers();
void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
void minkill(const bool steppers_off=false);
void quickstop_stepper();
extern bool Running;
inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; }
bool printingIsActive();
bool printingIsPaused();
void startOrResumeJob();
extern bool wait_for_heatup;
#if HAS_RESUME_CONTINUE
extern bool wait_for_user;
#endif
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
extern bool suspend_auto_report;
#endif
// Inactivity shutdown timer
extern millis_t max_inactive_time, stepper_inactive_time;
#if ENABLED(USE_CONTROLLER_FAN)
extern uint8_t controllerfan_speed;
#endif
#if ENABLED(PSU_CONTROL)
extern bool powersupply_on;
#define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0)
#define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0)
#if ENABLED(AUTO_POWER_CONTROL)
#define PSU_ON() powerManager.power_on()
#define PSU_OFF() powerManager.power_off()
#else
#define PSU_ON() PSU_PIN_ON()
#define PSU_OFF() PSU_PIN_OFF()
#endif
#endif
bool pin_is_protected(const pin_t pin);
void protected_pin_err();
#if HAS_SUICIDE
inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
#endif
#if ENABLED(G29_RETRY_AND_RECOVER)
void event_probe_recover();
void event_probe_failure();
#endif
extern const char NUL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[],
SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];

View file

@ -28,7 +28,7 @@
* - https://github.com/grbl/grbl
*/
#include "Marlin.h"
#include "MarlinCore.h"
#include "core/utility.h"
#include "lcd/ultralcd.h"
@ -177,11 +177,12 @@
#include "feature/prusa_MMU2/mmu2.h"
#endif
#if HAS_DRIVER(L6470)
#include "libs/L6470/L6470_Marlin.h"
#if HAS_L64XX
#include "libs/L64XX/L64XX_Marlin.h"
#endif
const char NUL_STR[] PROGMEM = "",
M112_KILL_STR[] PROGMEM = "M112 Shutdown",
G28_STR[] PROGMEM = "G28",
M21_STR[] PROGMEM = "M21",
M23_STR[] PROGMEM = "M23 %s",
@ -406,7 +407,7 @@ void startOrResumeJob() {
thermalManager.zero_fan_speeds();
wait_for_heatup = false;
#if ENABLED(POWER_LOSS_RECOVERY)
card.removeJobRecoveryFile();
recovery.purge();
#endif
#ifdef EVENT_GCODE_SD_STOP
queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
@ -605,7 +606,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
#endif
#if ENABLED(MONITOR_L6470_DRIVER_STATUS)
L6470.monitor_driver();
L64xxManager.monitor_driver();
#endif
// Limit check_axes_activity frequency to 10Hz
@ -618,7 +619,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
#if PIN_EXISTS(FET_SAFETY)
static millis_t FET_next;
if (ELAPSED(ms, FET_next)) {
FET_next = ms + FET_SAFETY_DELAY; // 2uS pulse every FET_SAFETY_DELAY mS
FET_next = ms + FET_SAFETY_DELAY; // 2µs pulse every FET_SAFETY_DELAY mS
OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED);
DELAY_US(2);
WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
@ -822,8 +823,12 @@ void setup() {
HAL_init();
#if HAS_DRIVER(L6470)
L6470.init(); // setup SPI and then init chips
#if HAS_L64XX
L64xxManager.init(); // Set up SPI, init drivers
#endif
#if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode
#endif
#if ENABLED(MAX7219_DEBUG)
@ -1128,10 +1133,9 @@ void setup() {
* - Call inactivity manager
*/
void loop() {
do {
for (;;) {
idle(); // Do an idle first so boot is slightly faster
idle();
#if ENABLED(SDSUPPORT)
card.checkautostart();
@ -1141,5 +1145,10 @@ void loop() {
queue.advance();
endstops.event_handler();
}
} while (false // Return to caller for best compatibility
#ifdef __AVR__
|| true // Loop forever on slower (AVR) boards
#endif
);
}

124
Marlin/src/MarlinCore.h Normal file
View file

@ -0,0 +1,124 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "inc/MarlinConfig.h"
#ifdef DEBUG_GCODE_PARSER
#include "gcode/parser.h"
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#if HAS_L64XX
#include "libs/L64XX/L64XX_Marlin.h"
extern uint8_t axis_known_position;
#endif
void stop();
void idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
bool no_stepper_sleep = false // pass true to keep steppers from disabling on timeout
#endif
);
void manage_inactivity(const bool ignore_stepper_queue=false);
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h"
extern TWIBus i2c;
#endif
#if ENABLED(G38_PROBE_TARGET)
extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type
extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed
#endif
/**
* The axis order in all axis related arrays is X, Y, Z, E
*/
void enable_e_steppers();
void enable_all_steppers();
void disable_e_stepper(const uint8_t e);
void disable_e_steppers();
void disable_all_steppers();
void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
void minkill(const bool steppers_off=false);
void quickstop_stepper();
extern bool Running;
inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; }
bool printingIsActive();
bool printingIsPaused();
void startOrResumeJob();
extern bool wait_for_heatup;
#if HAS_RESUME_CONTINUE
extern bool wait_for_user;
#endif
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
extern bool suspend_auto_report;
#endif
// Inactivity shutdown timer
extern millis_t max_inactive_time, stepper_inactive_time;
#if ENABLED(USE_CONTROLLER_FAN)
extern uint8_t controllerfan_speed;
#endif
#if ENABLED(PSU_CONTROL)
extern bool powersupply_on;
#define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0)
#define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0)
#if ENABLED(AUTO_POWER_CONTROL)
#define PSU_ON() powerManager.power_on()
#define PSU_OFF() powerManager.power_off()
#else
#define PSU_ON() PSU_PIN_ON()
#define PSU_OFF() PSU_PIN_OFF()
#endif
#endif
bool pin_is_protected(const pin_t pin);
void protected_pin_err();
#if HAS_SUICIDE
inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
#endif
#if ENABLED(G29_RETRY_AND_RECOVER)
void event_probe_recover();
void event_probe_failure();
#endif
extern const char NUL_STR[], M112_KILL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[],
SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];

View file

@ -90,17 +90,18 @@
#define BOARD_RAMPS_ENDER_4 1134 // Creality: Ender-4, CR-8
#define BOARD_RAMPS_CREALITY 1135 // Creality: CR10S, CR20, CR-X
#define BOARD_RAMPS_DAGOMA 1136 // Dagoma F5
#define BOARD_FYSETC_F6_13 1137 // FYSETC F6
#define BOARD_DUPLICATOR_I3_PLUS 1138 // Wanhao Duplicator i3 Plus
#define BOARD_VORON 1139 // VORON Design
#define BOARD_TRONXY_V3_1_0 1140 // Tronxy TRONXY-V3-1.0
#define BOARD_Z_BOLT_X_SERIES 1141 // Z-Bolt X Series
#define BOARD_TT_OSCAR 1142 // TT OSCAR
#define BOARD_OVERLORD 1143 // Overlord/Overlord Pro
#define BOARD_HJC2560C_REV1 1144 // ADIMLab Gantry v1
#define BOARD_HJC2560C_REV2 1145 // ADIMLab Gantry v2
#define BOARD_TANGO 1146 // BIQU Tango V1
#define BOARD_MKS_GEN_L_V2 1147 // MKS GEN L V2
#define BOARD_FYSETC_F6_13 1137 // FYSETC F6 1.3
#define BOARD_FYSETC_F6_14 1138 // FYSETC F6 1.4
#define BOARD_DUPLICATOR_I3_PLUS 1139 // Wanhao Duplicator i3 Plus
#define BOARD_VORON 1140 // VORON Design
#define BOARD_TRONXY_V3_1_0 1141 // Tronxy TRONXY-V3-1.0
#define BOARD_Z_BOLT_X_SERIES 1142 // Z-Bolt X Series
#define BOARD_TT_OSCAR 1143 // TT OSCAR
#define BOARD_OVERLORD 1144 // Overlord/Overlord Pro
#define BOARD_HJC2560C_REV1 1145 // ADIMLab Gantry v1
#define BOARD_HJC2560C_REV2 1146 // ADIMLab Gantry v2
#define BOARD_TANGO 1147 // BIQU Tango V1
#define BOARD_MKS_GEN_L_V2 1148 // MKS GEN L V2
//
// RAMBo and derivatives
@ -138,6 +139,7 @@
#define BOARD_GT2560_V3_A20 1318 // Geeetech GT2560 Rev B for A20(M/D)
#define BOARD_EINSTART_S 1319 // Einstart retrofit
#define BOARD_WANHAO_ONEPLUS 1320 // Wanhao 0ne+ i3 Mini
#define BOARD_LEAPFROG_XEED2015 1321 // Leapfrog Xeed 2015
//
// ATmega1281, ATmega2561
@ -201,22 +203,28 @@
#define BOARD_RAMPS_14_RE_ARM_SF 2004 // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
#define BOARD_MKS_SBASE 2005 // MKS-Sbase (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZSMZ_MINI 2006 // AZSMZ Mini
#define BOARD_AZTEEG_X5_GT 2007 // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_BIQU_BQ111_A4 2008 // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_SELENA_COMPACT 2009 // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1)
#define BOARD_COHESION3D_REMIX 2010 // Cohesion3D ReMix
#define BOARD_COHESION3D_MINI 2011 // Cohesion3D Mini
#define BOARD_SMOOTHIEBOARD 2012 // Smoothieboard
#define BOARD_AZTEEG_X5_MINI_WIFI 2013 // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
#define BOARD_BIQU_B300_V1_0 2014 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
#define BOARD_AZTEEG_X5_MINI 2015 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
#define BOARD_MKS_SGEN 2016 // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_MKS_SGEN_L 2017 // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_TH3D_EZBOARD 2018 // TH3D EZBoard v1.0
#define BOARD_GMARSH_X6_REV1 2019 // GMARSH X6 board, revision 1 prototype
#define BOARD_BIGTREE_SKR_V1_1 2020 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BIGTREE_SKR_V1_3 2021 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BIGTREE_SKR_V1_4 2022 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BIQU_BQ111_A4 2007 // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed)
#define BOARD_SELENA_COMPACT 2008 // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1)
#define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
#define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6 board, revision 1 prototype
#define BOARD_BIGTREE_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BIGTREE_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BIGTREE_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
//
// LPC1769 ARM Cortex M3
//
#define BOARD_MKS_SGEN 2500 // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZTEEG_X5_GT 2501 // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_AZTEEG_X5_MINI 2502 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
#define BOARD_AZTEEG_X5_MINI_WIFI 2503 // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
#define BOARD_COHESION3D_REMIX 2504 // Cohesion3D ReMix
#define BOARD_COHESION3D_MINI 2505 // Cohesion3D Mini
#define BOARD_SMOOTHIEBOARD 2506 // Smoothieboard
#define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0
#define BOARD_BIGTREE_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed)
//
// SAM3X8E ARM Cortex M3
@ -248,6 +256,7 @@
#define BOARD_ARCHIM1 3023 // UltiMachine Archim1 (with DRV8825 drivers)
#define BOARD_ARCHIM2 3024 // UltiMachine Archim2 (with TMC2130 drivers)
#define BOARD_ALLIGATOR 3025 // Alligator Board R2
#define BOARD_CNCONTROLS_15D 3026 // Cartesio CN Controls V15 on DUE
//
// SAM3X8C ARM Cortex M3
@ -303,7 +312,7 @@
#define BOARD_RUMBA32 4203 // RUMBA32 STM32F4-based controller
#define BOARD_BLACK_STM32F407VE 4204 // BLACK_STM32F407VE
#define BOARD_BLACK_STM32F407ZE 4205 // BLACK_STM32F407ZE
#define BOARD_STEVAL 4206 // STEVAL-3DP001V1 3D PRINTER BOARD
#define BOARD_STEVAL_3DP001V1 4206 // STEVAL-3DP001V1 3D PRINTER BOARD
#define BOARD_BIGTREE_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
#define BOARD_BIGTREE_BTT002_V1_0 4208 // BigTreeTech BTT002 v1.0 (STM32F407VE)
#define BOARD_LERDGE_K 4209 // Lerdge K (STM32F407ZG)

View file

@ -23,30 +23,33 @@
#include "../inc/MarlinConfigPre.h"
#define _A4988 0x001
#define _A5984 0x002
#define _DRV8825 0x003
#define _LV8729 0x004
#define _L6470 0x105
#define _TB6560 0x006
#define _TB6600 0x007
#define _TMC2100 0x008
#define _TMC2130 2130
#define _TMC2130_STANDALONE 0x009
#define _TMC2160 2160
#define _TMC2160_STANDALONE 2161
#define _TMC2208 2208
#define _TMC2208_STANDALONE 0x00A
#define _TMC2209 2209
#define _TMC2209_STANDALONE 0x00D
#define _TMC26X 0x10B
#define _TMC26X_STANDALONE 0x00B
#define _TMC2660 2660
#define _TMC2660_STANDALONE 0x00C
#define _TMC5130 5130
#define _TMC5130_STANDALONE 5131
#define _TMC5160 5160
#define _TMC5160_STANDALONE 5161
#define _A4988 0x4988
#define _A5984 0x5984
#define _DRV8825 0x8825
#define _LV8729 0x8729
#define _L6470 0x6470
#define _L6474 0x6474
#define _L6480 0x6480
#define _POWERSTEP01 0xF00D
#define _TB6560 0x6560
#define _TB6600 0x6600
#define _TMC2100 0x2100
#define _TMC2130 0x2130A
#define _TMC2130_STANDALONE 0x2130B
#define _TMC2160 0x2160A
#define _TMC2160_STANDALONE 0x2160B
#define _TMC2208 0x2208A
#define _TMC2208_STANDALONE 0x2208B
#define _TMC2209 0x2209A
#define _TMC2209_STANDALONE 0x2209B
#define _TMC26X 0x2600A
#define _TMC26X_STANDALONE 0x2600B
#define _TMC2660 0x2660A
#define _TMC2660_STANDALONE 0x2660B
#define _TMC5130 0x5130A
#define _TMC5130_STANDALONE 0x5130B
#define _TMC5160 0x5160A
#define _TMC5160_STANDALONE 0x5160B
#define _DRIVER_ID(V) _CAT(_, V)
#define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _CAT(_, T))
@ -54,26 +57,35 @@
#define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
#define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
#define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
#if EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE)
#define AXIS_DRIVER_TYPE_X2(T) _AXIS_DRIVER_TYPE(X2,T)
#else
#define AXIS_DRIVER_TYPE_X2(T) false
#endif
#define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
#define AXIS_DRIVER_TYPE_Z2(T) (Z_MULTI_STEPPER_DRIVERS && _AXIS_DRIVER_TYPE(Z2,T))
#define AXIS_DRIVER_TYPE_Z3(T) (ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Z3,T))
#define AXIS_DRIVER_TYPE_Z2(T) (NUM_Z_STEPPER_DRIVERS >= 2 && _AXIS_DRIVER_TYPE(Z2,T))
#define AXIS_DRIVER_TYPE_Z3(T) (NUM_Z_STEPPER_DRIVERS >= 3 && _AXIS_DRIVER_TYPE(Z3,T))
#define AXIS_DRIVER_TYPE_Z4(T) (NUM_Z_STEPPER_DRIVERS >= 4 && _AXIS_DRIVER_TYPE(Z4,T))
#define AXIS_DRIVER_TYPE_E0(T) (E_STEPPERS > 0 && _AXIS_DRIVER_TYPE(E0,T))
#define AXIS_DRIVER_TYPE_E1(T) (E_STEPPERS > 1 && _AXIS_DRIVER_TYPE(E1,T))
#define AXIS_DRIVER_TYPE_E2(T) (E_STEPPERS > 2 && _AXIS_DRIVER_TYPE(E2,T))
#define AXIS_DRIVER_TYPE_E3(T) (E_STEPPERS > 3 && _AXIS_DRIVER_TYPE(E3,T))
#define AXIS_DRIVER_TYPE_E4(T) (E_STEPPERS > 4 && _AXIS_DRIVER_TYPE(E4,T))
#define AXIS_DRIVER_TYPE_E5(T) (E_STEPPERS > 5 && _AXIS_DRIVER_TYPE(E5,T))
#define AXIS_DRIVER_TYPE_E6(T) (E_STEPPERS > 6 && _AXIS_DRIVER_TYPE(E6,T))
#define AXIS_DRIVER_TYPE_E7(T) (E_STEPPERS > 7 && _AXIS_DRIVER_TYPE(E7,T))
#define AXIS_DRIVER_TYPE(A,T) AXIS_DRIVER_TYPE_##A(T)
#define HAS_E_DRIVER(T) ( AXIS_DRIVER_TYPE_E0(T) || AXIS_DRIVER_TYPE_E1(T) \
|| AXIS_DRIVER_TYPE_E2(T) || AXIS_DRIVER_TYPE_E3(T) \
|| AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) )
|| AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) \
|| AXIS_DRIVER_TYPE_E6(T) || AXIS_DRIVER_TYPE_E7(T) )
#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_X2(T) \
|| AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Y2(T) \
|| AXIS_DRIVER_TYPE_Z(T) || AXIS_DRIVER_TYPE_Z2(T) || AXIS_DRIVER_TYPE_Z3(T) \
|| AXIS_DRIVER_TYPE_Z(T) || AXIS_DRIVER_TYPE_Z2(T) \
|| AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) \
|| HAS_E_DRIVER(T) )
// Test for supported TMC drivers that require advanced configuration
@ -86,6 +98,18 @@
|| HAS_DRIVER(TMC5130) \
|| HAS_DRIVER(TMC5160) )
#define HAS_TRINAMIC_STANDALONE ( HAS_DRIVER(TMC2130_STANDALONE) \
|| HAS_DRIVER(TMC2208_STANDALONE) \
|| HAS_DRIVER(TMC2209_STANDALONE) \
|| HAS_DRIVER(TMC26X_STANDALONE) \
|| HAS_DRIVER(TMC2660_STANDALONE) \
|| HAS_DRIVER(TMC5130_STANDALONE) \
|| HAS_DRIVER(TMC5160_STANDALONE) \
|| HAS_DRIVER(TMC2160_STANDALONE) )
#define HAS_TMCX1X0 ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
|| HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160))
#define HAS_TMC220x (HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209))
#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
@ -107,6 +131,8 @@
#define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) \
|| AXIS_DRIVER_TYPE(A,TMC2209) )
#define AXIS_HAS_SW_SERIAL(A) ((AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL)))
#define AXIS_HAS_STALLGUARD(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|| AXIS_DRIVER_TYPE(A,TMC2209) \
@ -121,19 +147,20 @@
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|| AXIS_DRIVER_TYPE(A,TMC5160) )
#define HAS_TMC_E_DRIVER ( HAS_E_DRIVER(TMC2130) \
|| HAS_E_DRIVER(TMC2160) \
|| HAS_E_DRIVER(TMC2660) \
|| HAS_E_DRIVER(TMC2209) \
|| HAS_E_DRIVER(TMC5130) \
|| HAS_E_DRIVER(TMC5160) )
#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \
|| AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \
|| AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) \
|| AXIS_HAS_##T(Z3) \
|| AXIS_HAS_##T(E0) || AXIS_HAS_##T(E1) \
|| AXIS_HAS_##T(E2) || AXIS_HAS_##T(E3) \
|| AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) \
|| AXIS_HAS_##T(E6) || AXIS_HAS_##T(E7) )
#define HAS_STEALTHCHOP ANY_AXIS_HAS(STEALTHCHOP)
#define HAS_STALLGUARD ANY_AXIS_HAS(STALLGUARD)
#define TMC_HAS_SPI ANY_AXIS_HAS(SPI)
#define TMC_HAS_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL)
#define HAS_TMC_STANDALONE_E_DRIVER ( HAS_E_DRIVER(TMC2130_STANDALONE) \
|| HAS_E_DRIVER(TMC2160_STANDALONE) \
|| HAS_E_DRIVER(TMC2660_STANDALONE) \
|| HAS_E_DRIVER(TMC2209_STANDALONE) \
|| HAS_E_DRIVER(TMC5130_STANDALONE) \
|| HAS_E_DRIVER(TMC5160_STANDALONE) )
//
// Stretching 'drivers.h' to include LPC/SAMD51 SD options
//
@ -142,3 +169,8 @@
#define _SDCARD_CUSTOM_CABLE 3
#define _SDCARD_ID(V) _CAT(_SDCARD_, V)
#define SD_CONNECTION_IS(V) (_SDCARD_ID(SDCARD_CONNECTION) == _SDCARD_ID(V))
#define HAS_L64XX (HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01))
#define HAS_L64XX_NOT_L6474 (HAS_L64XX && !HAS_DRIVER(L6474))
#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01))

View file

@ -195,6 +195,8 @@
#define MSG_Z2_MAX "z2_max"
#define MSG_Z3_MIN "z3_min"
#define MSG_Z3_MAX "z3_max"
#define MSG_Z4_MIN "z4_min"
#define MSG_Z4_MAX "z4_max"
#define MSG_Z_PROBE "z_probe"
#define MSG_FILAMENT_RUNOUT_SENSOR "filament"
#define MSG_PROBE_OFFSET "Probe Offset"
@ -220,6 +222,10 @@
#define MSG_SOFT_MIN " Min: "
#define MSG_SOFT_MAX " Max: "
#define MSG_SAVED_POS "Position saved"
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot. Total: "
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir "
#define MSG_SD_INIT_FAIL "SD init fail"
#define MSG_SD_VOL_INIT_FAIL "volume.init failed"
@ -333,6 +339,7 @@
#define MSG_Y2 "Y2"
#define MSG_Z2 "Z2"
#define MSG_Z3 "Z3"
#define MSG_Z4 "Z4"
#define LCD_STR_A MSG_A
#define LCD_STR_B MSG_B
@ -356,6 +363,8 @@
#define LCD_STR_N3 "3"
#define LCD_STR_N4 "4"
#define LCD_STR_N5 "5"
#define LCD_STR_N6 "6"
#define LCD_STR_N7 "7"
#else
#define LCD_FIRST_TOOL '1'
#define LCD_STR_N0 "1"
@ -364,6 +373,8 @@
#define LCD_STR_N3 "4"
#define LCD_STR_N4 "5"
#define LCD_STR_N5 "6"
#define LCD_STR_N6 "7"
#define LCD_STR_N7 "8"
#endif
#define LCD_STR_E0 "E" LCD_STR_N0
@ -372,6 +383,8 @@
#define LCD_STR_E3 "E" LCD_STR_N3
#define LCD_STR_E4 "E" LCD_STR_N4
#define LCD_STR_E5 "E" LCD_STR_N5
#define LCD_STR_E6 "E" LCD_STR_N6
#define LCD_STR_E7 "E" LCD_STR_N7
#include "multi_language.h" // Allow multiple languages

View file

@ -29,7 +29,7 @@ static const char errormagic[] PROGMEM = "Error:";
static const char echomagic[] PROGMEM = "echo:";
#if NUM_SERIAL > 1
int8_t serial_port_index = SERIAL_PORT;
int8_t serial_port_index = 0;
#endif
void serialprintPGM(PGM_P str) {
@ -58,12 +58,10 @@ void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(MSG_ON) :
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
void print_bin(const uint16_t val) {
uint16_t mask = 0x8000;
void print_bin(uint16_t val) {
for (uint8_t i = 16; i--;) {
if (i && !(i % 4)) SERIAL_CHAR(' ');
SERIAL_CHAR((val & mask) ? '1' : '0');
mask >>= 1;
SERIAL_CHAR('0' + TEST(val, i));
if (!(i & 0x3) && i) SERIAL_CHAR(' ');
}
}

View file

@ -66,7 +66,6 @@ extern uint8_t marlin_debug_flags;
#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
#define PORT_RESTORE() _PORT_RESTORE(1)
#define SERIAL_CHAR(x) SERIAL_OUT(write, x)
#define SERIAL_ECHO(x) SERIAL_OUT(print, x)
#define SERIAL_ECHO_F(V...) SERIAL_OUT(print, V)
#define SERIAL_ECHOLN(x) SERIAL_OUT(println, x)
@ -83,6 +82,22 @@ extern uint8_t marlin_debug_flags;
#define SERIAL_FLUSHTX()
#endif
// Print up to 10 chars from a list
#define __CHAR_N(N,V...) _CHAR_##N(V)
#define _CHAR_N(N,V...) __CHAR_N(N,V)
#define _CHAR_1(c) SERIAL_OUT(write, c)
#define _CHAR_2(a,b) do{ _CHAR_1(a); _CHAR_1(b); }while(0)
#define _CHAR_3(a,V...) do{ _CHAR_1(a); _CHAR_2(V); }while(0)
#define _CHAR_4(a,V...) do{ _CHAR_1(a); _CHAR_3(V); }while(0)
#define _CHAR_5(a,V...) do{ _CHAR_1(a); _CHAR_4(V); }while(0)
#define _CHAR_6(a,V...) do{ _CHAR_1(a); _CHAR_5(V); }while(0)
#define _CHAR_7(a,V...) do{ _CHAR_1(a); _CHAR_6(V); }while(0)
#define _CHAR_8(a,V...) do{ _CHAR_1(a); _CHAR_7(V); }while(0)
#define _CHAR_9(a,V...) do{ _CHAR_1(a); _CHAR_8(V); }while(0)
#define _CHAR_10(a,V...) do{ _CHAR_1(a); _CHAR_9(V); }while(0)
#define SERIAL_CHAR(V...) _CHAR_N(NUM_ARGS(V),V)
// Print up to 12 pairs of values. Odd elements auto-wrapped in PSTR().
#define __SEP_N(N,V...) _SEP_##N(V)
#define _SEP_N(N,V...) __SEP_N(N,V)

View file

@ -43,11 +43,7 @@ enum AxisEnum : uint8_t {
E_AXIS = 3,
X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6,
E0_AXIS = 3,
E1_AXIS = 4,
E2_AXIS = 5,
E3_AXIS = 6,
E4_AXIS = 7,
E5_AXIS = 8,
E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS,
ALL_AXES = 0xFE, NO_AXIS = 0xFF
};

View file

@ -22,7 +22,7 @@
#include "utility.h"
#include "../Marlin.h"
#include "../MarlinCore.h"
#include "../module/temperature.h"
void safe_delay(millis_t ms) {
@ -81,6 +81,10 @@ void safe_delay(millis_t ms) {
);
#if HAS_BED_PROBE
#if !HAS_PROBE_XY_OFFSET
SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " (");
#else
SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
if (probe_offset.x > 0)
SERIAL_ECHOPGM(" (Right");
@ -108,13 +112,18 @@ void safe_delay(millis_t ms) {
else if (probe_offset.x != 0)
SERIAL_ECHOPGM("-Center");
SERIAL_ECHOPGM(" & ");
#endif
if (probe_offset.z < 0)
SERIAL_ECHOPGM(" & Below");
SERIAL_ECHOPGM("Below");
else if (probe_offset.z > 0)
SERIAL_ECHOPGM(" & Above");
SERIAL_ECHOPGM("Above");
else
SERIAL_ECHOPGM(" & Same Z as");
SERIAL_ECHOPGM("Same Z as");
SERIAL_ECHOLNPGM(" Nozzle)");
#endif
#if HAS_ABL_OR_UBL
@ -139,8 +148,7 @@ void safe_delay(millis_t ms) {
SERIAL_ECHOPGM("ABL Adjustment X");
LOOP_XYZ(a) {
float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
SERIAL_CHAR(' ');
SERIAL_CHAR('X' + char(a));
SERIAL_CHAR(' ', 'X' + char(a));
if (v > 0) SERIAL_CHAR('+');
SERIAL_ECHO(v);
}

View file

@ -45,7 +45,7 @@
#include "../module/planner.h"
#include "../module/stepper.h"
#include "../Marlin.h"
#include "../MarlinCore.h"
#include "../HAL/shared/Delay.h"
#define HAS_SIDE_BY_SIDE (ENABLED(MAX7219_SIDE_BY_SIDE) && MAX7219_NUMBER_UNITS > 1)
@ -455,15 +455,19 @@ void Max7219::register_setup() {
#ifdef MAX7219_INIT_TEST
#if MAX7219_INIT_TEST == 2
#define MAX7219_LEDS (MAX7219_X_LEDS * MAX7219_Y_LEDS)
void Max7219::spiral(const bool on, const uint16_t del) {
constexpr int8_t way[] = { 1, 0, 0, 1, -1, 0, 0, -1 };
constexpr int8_t way[][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
int8_t px = 0, py = 0, dir = 0;
for (uint8_t i = MAX7219_X_LEDS * MAX7219_Y_LEDS; i--;) {
for (IF<(MAX7219_LEDS > 255), uint16_t, uint8_t>::type i = MAX7219_LEDS; i--;) {
led_set(px, py, on);
delay(del);
const int8_t x = px + way[dir], y = py + way[dir + 1];
if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on) dir = (dir + 2) & 0x7;
px += way[dir]; py += way[dir + 1];
const int8_t x = px + way[dir][0], y = py + way[dir][1];
if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on)
dir = (dir + 1) & 0x3;
px += way[dir][0];
py += way[dir][1];
}
}

View file

@ -25,7 +25,7 @@
#if ENABLED(BABYSTEPPING)
#include "babystep.h"
#include "../Marlin.h"
#include "../MarlinCore.h"
#include "../module/planner.h"
#include "../module/stepper.h"

View file

@ -86,14 +86,18 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
#endif
if (planner.leveling_active) { // leveling from on to off
if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling ON", current_position);
// change unleveled current_position to physical current_position without moving steppers.
planner.apply_leveling(current_position);
planner.leveling_active = false; // disable only AFTER calling apply_leveling
if (DEBUGGING(LEVELING)) DEBUG_POS("...Now OFF", current_position);
}
else { // leveling from off to on
if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling OFF", current_position);
planner.leveling_active = true; // enable BEFORE calling unapply_leveling, otherwise ignored
// change physical current_position to unleveled current_position without moving steppers.
planner.unapply_leveling(current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("...Now ON", current_position);
}
sync_plan_position();
@ -207,8 +211,7 @@ void reset_bed_level() {
#endif
}
#ifdef SCAD_MESH_OUTPUT
SERIAL_CHAR(' ');
SERIAL_CHAR(']'); // close sub-array
SERIAL_CHAR(' ', ']'); // close sub-array
if (y < sy - 1) SERIAL_CHAR(',');
#endif
SERIAL_EOL();
@ -244,7 +247,7 @@ void reset_bed_level() {
current_position = pos;
#if ENABLED(LCD_BED_LEVELING)
ui.wait_for_bl_move = false;
ui.wait_for_move = false;
#endif
}

View file

@ -176,7 +176,7 @@
// Add XY probe offset from extruder because probe_at_point() subtracts them when
// moving to the XY position to be measured. This ensures better agreement between
// the current Z position after G28 and the mesh values.
const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + xy_pos_t(probe_offset));
const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy);
if (!lcd) SERIAL_EOL();
for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

View file

@ -26,7 +26,7 @@
#include "../bedlevel.h"
#include "../../../Marlin.h"
#include "../../../MarlinCore.h"
#include "../../../HAL/shared/persistent_store_api.h"
#include "../../../libs/hex_print_routines.h"
#include "../../../module/configuration_store.h"
@ -450,7 +450,7 @@
SERIAL_ECHO(g29_pos.y);
SERIAL_ECHOLNPGM(").\n");
}
const xy_pos_t near = g29_pos + probe_offset;
const xy_pos_t near = g29_pos + probe_offset_xy;
probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
report_current_position();
@ -468,6 +468,7 @@
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
if (parser.seen('C') && !xy_seen) {
/**
* Use a good default location for the path.
* The flipped > and < operators in these comparisons is intentional.
@ -479,8 +480,8 @@
#if IS_KINEMATIC
X_HOME_POS, Y_HOME_POS
#else
probe_offset.x > 0 ? X_BED_SIZE : 0,
probe_offset.y < 0 ? Y_BED_SIZE : 0
probe_offset_xy.x > 0 ? X_BED_SIZE : 0,
probe_offset_xy.y < 0 ? Y_BED_SIZE : 0
#endif
);
}
@ -805,8 +806,8 @@
restore_ubl_active_state_and_leave();
do_blocking_move_to_xy(
constrain(near.x - probe_offset.x, MESH_MIN_X, MESH_MAX_X),
constrain(near.y - probe_offset.y, MESH_MIN_Y, MESH_MAX_Y)
constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X),
constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
);
}
@ -1293,7 +1294,7 @@
closest.distance = -99999.9f;
// Get the reference position, either nozzle or probe
const xy_pos_t ref = probe_relative ? pos + probe_offset : pos;
const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos;
float best_so_far = 99999.99f;

View file

@ -32,7 +32,7 @@
#include "../../../module/delta.h"
#endif
#include "../../../Marlin.h"
#include "../../../MarlinCore.h"
#include <math.h>
#if !UBL_SEGMENTED

View file

@ -58,7 +58,9 @@ void update_case_light() {
if (case_light_arg_flag && case_light_on)
case_light_brightness = case_light_brightness_sav; // restore last brightens if this is an S1 argument
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL) || NONE(CASE_LIGHT_USE_NEOPIXEL, CASE_LIGHT_NO_BRIGHTNESS)
const uint8_t i = case_light_on ? case_light_brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
#endif
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
@ -71,13 +73,13 @@ void update_case_light() {
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
if (PWM_PIN(CASE_LIGHT_PIN))
analogWrite(pin_t(CASE_LIGHT_PIN),
analogWrite(pin_t(CASE_LIGHT_PIN), (
#if CASE_LIGHT_MAX_PWM == 255
n10ct
#else
map(n10ct, 0, 255, 0, CASE_LIGHT_MAX_PWM)
#endif
);
));
else
#endif
{

View file

@ -36,27 +36,30 @@ void controllerfan_update() {
if (ELAPSED(ms, nextMotorCheck)) {
nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s
const bool xory = X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON;
const bool xory = X_ENABLE_READ() == bool(X_ENABLE_ON) || Y_ENABLE_READ() == bool(Y_ENABLE_ON);
// If any of the drivers or the bed are enabled...
if (xory || Z_ENABLE_READ() == Z_ENABLE_ON
if (xory || Z_ENABLE_READ() == bool(Z_ENABLE_ON)
#if HAS_HEATED_BED
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
#if HAS_X2_ENABLE
|| X2_ENABLE_READ() == X_ENABLE_ON
|| X2_ENABLE_READ() == bool(X_ENABLE_ON)
#endif
#if HAS_Y2_ENABLE
|| Y2_ENABLE_READ() == Y_ENABLE_ON
|| Y2_ENABLE_READ() == bool(Y_ENABLE_ON)
#endif
#if HAS_Z2_ENABLE
|| Z2_ENABLE_READ() == Z_ENABLE_ON
|| Z2_ENABLE_READ() == bool(Z_ENABLE_ON)
#endif
#if HAS_Z3_ENABLE
|| Z3_ENABLE_READ() == Z_ENABLE_ON
|| Z3_ENABLE_READ() == bool(Z_ENABLE_ON)
#endif
#if HAS_Z4_ENABLE
|| Z4_ENABLE_READ() == bool(Z_ENABLE_ON)
#endif
#if E_STEPPERS
#define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
#define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == bool(E_ENABLE_ON)
REPEAT(E_STEPPERS, _OR_ENABLED_E)
#endif
) {

View file

@ -10,7 +10,7 @@
#include "dac_dac084s085.h"
#include "../../Marlin.h"
#include "../../MarlinCore.h"
#include "../../module/stepper.h"
#include "../../HAL/shared/Delay.h"

View file

@ -43,7 +43,7 @@ xyze_uint_t mcp4728_values;
*/
void mcp4728_init() {
Wire.begin();
Wire.requestFrom(int(DAC_DEV_ADDRESS), 24);
Wire.requestFrom(I2C_ADDRESS(DAC_DEV_ADDRESS), 24);
while (Wire.available()) {
char deviceID = Wire.read(),
hiByte = Wire.read(),

View file

@ -29,6 +29,24 @@
#include <Wire.h>
/**
* The following three macros are only used in this piece of code related to mcp4728.
* They are defined in the standard Arduino framework but could be undefined in 32 bits Arduino frameworks.
* (For instance not defined in Arduino lpc176x framework)
* So we have to define them if needed.
*/
#ifndef word
#define word(h, l) ((uint8_t) ((h << 8) | l))
#endif
#ifndef lowByte
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#endif
#ifndef highByte
#define highByte(w) ((uint8_t) ((w) >> 8))
#endif
#define defaultVDD DAC_STEPPER_MAX //was 5000 but differs with internal Vref
#define BASE_ADDR 0x60
#define RESET 0b00000110

View file

@ -68,7 +68,7 @@ void dac_current_percent(uint8_t channel, float val) {
void dac_current_raw(uint8_t channel, uint16_t val) {
if (!dac_present) return;
NOMORE(val, DAC_STEPPER_MAX);
NOMORE(val, uint16_t(DAC_STEPPER_MAX));
mcp4728_analogWrite(dac_order[channel], val);
mcp4728_simpleCommand(UPDATE);

View file

@ -47,7 +47,7 @@ static byte current_to_wiper(const float current) {
return byte(CEIL(float((DIGIPOT_I2C_FACTOR * current))));
}
static void i2c_send(const byte addr, const byte a, const byte b) {
static void digipot_i2c_send(const byte addr, const byte a, const byte b) {
#if MB(MKS_SBASE)
digipot_mcp4451_start(addr);
digipot_mcp4451_send_byte(a);
@ -67,17 +67,17 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
const byte addr = channel < 4 ? DIGIPOT_I2C_ADDRESS_A : DIGIPOT_I2C_ADDRESS_B; // channel 0-3 vs 4-7
// Initial setup
i2c_send(addr, 0x40, 0xFF);
i2c_send(addr, 0xA0, 0xFF);
digipot_i2c_send(addr, 0x40, 0xFF);
digipot_i2c_send(addr, 0xA0, 0xFF);
// Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel & 0x3], current_to_wiper(_MIN(float(_MAX(current, 0)), DIGIPOT_I2C_MAX_CURRENT)));
digipot_i2c_send(addr, addresses[channel & 0x3], current_to_wiper(_MIN(float(_MAX(current, 0)), DIGIPOT_I2C_MAX_CURRENT)));
}
void digipot_i2c_init() {
#if MB(MKS_SBASE)
digipot_mcp4451_init();
configure_i2c(16); // Setting clock_option to 16 ensure the I2C bus is initialized at 400kHz
#else
Wire.begin();
#endif

View file

@ -42,25 +42,40 @@ Joystick joystick;
#if HAS_JOY_ADC_X
temp_info_t Joystick::x; // = { 0 }
#if ENABLED(INVERT_JOY_X)
#define JOY_X(N) (16383 - (N))
#else
#define JOY_X(N) (N)
#endif
#endif
#if HAS_JOY_ADC_Y
temp_info_t Joystick::y; // = { 0 }
#if ENABLED(INVERT_JOY_Y)
#define JOY_Y(N) (16383 - (N))
#else
#define JOY_Y(N) (N)
#endif
#endif
#if HAS_JOY_ADC_Z
temp_info_t Joystick::z; // = { 0 }
#if ENABLED(INVERT_JOY_Z)
#define JOY_Z(N) (16383 - (N))
#else
#define JOY_Z(N) (N)
#endif
#endif
#if ENABLED(JOYSTICK_DEBUG)
void Joystick::report() {
SERIAL_ECHOPGM("Joystick");
#if HAS_JOY_ADC_X
SERIAL_ECHOPAIR_P(SP_X_STR, x.raw);
SERIAL_ECHOPAIR_P(SP_X_STR, JOY_X(x.raw));
#endif
#if HAS_JOY_ADC_Y
SERIAL_ECHOPAIR_P(SP_Y_STR, y.raw);
SERIAL_ECHOPAIR_P(SP_Y_STR, JOY_Y(y.raw));
#endif
#if HAS_JOY_ADC_Z
SERIAL_ECHOPAIR_P(SP_Z_STR, z.raw);
SERIAL_ECHOPAIR_P(SP_Z_STR, JOY_Z(z.raw));
#endif
#if HAS_JOY_ADC_EN
SERIAL_ECHO_TERNARY(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)");
@ -91,15 +106,15 @@ Joystick joystick;
#if HAS_JOY_ADC_X
static constexpr int16_t joy_x_limits[4] = JOY_X_LIMITS;
_normalize_joy(norm_jog.x, x.raw, joy_x_limits);
_normalize_joy(norm_jog.x, JOY_X(x.raw), joy_x_limits);
#endif
#if HAS_JOY_ADC_Y
static constexpr int16_t joy_y_limits[4] = JOY_Y_LIMITS;
_normalize_joy(norm_jog.y, y.raw, joy_y_limits);
_normalize_joy(norm_jog.y, JOY_Y(y.raw), joy_y_limits);
#endif
#if HAS_JOY_ADC_Z
static constexpr int16_t joy_z_limits[4] = JOY_Z_LIMITS;
_normalize_joy(norm_jog.z, z.raw, joy_z_limits);
_normalize_joy(norm_jog.z, JOY_Z(z.raw), joy_z_limits);
#endif
}

View file

@ -29,7 +29,7 @@
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#include "../Marlin.h"
#include "../MarlinCore.h"
#include "../gcode/gcode.h"
#include "../module/motion.h"
#include "../module/planner.h"
@ -352,7 +352,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
// Quickly purge
do_pause_e_move((FILAMENT_UNLOAD_PURGE_RETRACT + FILAMENT_UNLOAD_PURGE_LENGTH) * mix_multiplier,
planner.settings.max_feedrate_mm_s[E_AXIS] * mix_multiplier);
(FILAMENT_UNLOAD_PURGE_FEEDRATE) * mix_multiplier);
// Unload filament
#if FILAMENT_CHANGE_UNLOAD_ACCEL > 0

View file

@ -31,7 +31,7 @@
#include "power.h"
#include "../module/temperature.h"
#include "../module/stepper/indirection.h"
#include "../Marlin.h"
#include "../MarlinCore.h"
Power powerManager;

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