Merge tag '2.0.7' of https://github.com/MarlinFirmware/Marlin into master
This commit is contained in:
commit
09beed85c2
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -2,7 +2,7 @@
|
|||||||
name: Feature request
|
name: Feature request
|
||||||
about: Request a Feature
|
about: Request a Feature
|
||||||
title: "[FR] (feature request title)"
|
title: "[FR] (feature request title)"
|
||||||
labels: ''
|
labels: 'T: Feature Request'
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
4
.github/workflows/close-stale.yml
vendored
4
.github/workflows/close-stale.yml
vendored
@ -20,8 +20,8 @@ jobs:
|
|||||||
- uses: actions/stale@v3
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.'
|
stale-issue-message: 'This issue has had no activity in the last 30 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 7 days.'
|
||||||
days-before-stale: 30
|
days-before-stale: 30
|
||||||
days-before-close: 5
|
days-before-close: 7
|
||||||
stale-issue-label: 'stale-closing-soon'
|
stale-issue-label: 'stale-closing-soon'
|
||||||
exempt-issue-labels: 'T: Feature Request'
|
exempt-issue-labels: 'T: Feature Request'
|
||||||
|
2
.github/workflows/test-builds.yml
vendored
2
.github/workflows/test-builds.yml
vendored
@ -41,6 +41,7 @@ jobs:
|
|||||||
- mega2560
|
- mega2560
|
||||||
- teensy31
|
- teensy31
|
||||||
- teensy35
|
- teensy35
|
||||||
|
- teensy41
|
||||||
- SAMD51_grandcentral_m4
|
- SAMD51_grandcentral_m4
|
||||||
|
|
||||||
# Extended AVR Environments
|
# Extended AVR Environments
|
||||||
@ -70,6 +71,7 @@ jobs:
|
|||||||
- mks_robin_stm32
|
- mks_robin_stm32
|
||||||
- ARMED
|
- ARMED
|
||||||
- FYSETC_S6
|
- FYSETC_S6
|
||||||
|
- STM32F070CB_malyan
|
||||||
- STM32F070RB_malyan
|
- STM32F070RB_malyan
|
||||||
- malyan_M300
|
- malyan_M300
|
||||||
- mks_robin_lite
|
- mks_robin_lite
|
||||||
|
@ -34,9 +34,8 @@
|
|||||||
* - Extra features
|
* - Extra features
|
||||||
*
|
*
|
||||||
* Advanced settings can be found in Configuration_adv.h
|
* Advanced settings can be found in Configuration_adv.h
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define CONFIGURATION_H_VERSION 020006
|
#define CONFIGURATION_H_VERSION 020007
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//============================= Getting Started =============================
|
//============================= Getting Started =============================
|
||||||
@ -395,6 +394,7 @@
|
|||||||
* 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
|
* 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v excitation (STM32 \ LPC176x....)
|
||||||
* 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB)
|
* 22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB)
|
||||||
* 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB)
|
* 23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB)
|
||||||
|
* 30 : Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K / B3950 (4.7k pullup)
|
||||||
* 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
|
* 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
|
||||||
* 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
|
* 60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
|
||||||
* 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
|
* 61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
|
||||||
@ -491,39 +491,18 @@
|
|||||||
//#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
|
//#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
|
||||||
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
|
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
|
||||||
// Set/get with gcode: M301 E[extruder number, 0-2]
|
// Set/get with gcode: M301 E[extruder number, 0-2]
|
||||||
|
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
||||||
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
|
// Specify between 1 and HOTENDS values per array.
|
||||||
|
// If fewer than EXTRUDER values are provided, the last element will be repeated.
|
||||||
// Ultimaker
|
#define DEFAULT_Kp_LIST { 22.20, 20.0 }
|
||||||
//#define DEFAULT_Kp 22.2
|
#define DEFAULT_Ki_LIST { 1.08, 1.0 }
|
||||||
//#define DEFAULT_Ki 1.08
|
#define DEFAULT_Kd_LIST { 114.00, 112.0 }
|
||||||
//#define DEFAULT_Kd 114
|
#else
|
||||||
|
|
||||||
// Wanhao Duplicator i3
|
|
||||||
//#define DEFAULT_Kp 29
|
|
||||||
//#define DEFAULT_Ki 2.00
|
|
||||||
//#define DEFAULT_Kd 97
|
|
||||||
|
|
||||||
// Defaults from https://www.itsalllost.com/wanhao-i3-32bit-upgrade/
|
|
||||||
//#define DEFAULT_Kp 17.45
|
|
||||||
//#define DEFAULT_Ki 0.84
|
|
||||||
//#define DEFAULT_Kd 90.41
|
|
||||||
|
|
||||||
// MakerGear
|
|
||||||
//#define DEFAULT_Kp 7.0
|
|
||||||
//#define DEFAULT_Ki 0.1
|
|
||||||
//#define DEFAULT_Kd 12
|
|
||||||
|
|
||||||
// Mendel Parts V9 on 12V
|
|
||||||
//#define DEFAULT_Kp 63.0
|
|
||||||
//#define DEFAULT_Ki 2.25
|
|
||||||
//#define DEFAULT_Kd 440
|
|
||||||
|
|
||||||
// Defaults from PID Tuning
|
// Defaults from PID Tuning
|
||||||
#define DEFAULT_Kp 23.66
|
#define DEFAULT_Kp 23.66
|
||||||
#define DEFAULT_Ki 1.42
|
#define DEFAULT_Ki 1.42
|
||||||
#define DEFAULT_Kd 98.72
|
#define DEFAULT_Kd 98.72
|
||||||
|
#endif
|
||||||
#endif // PIDTEMP
|
#endif // PIDTEMP
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -559,29 +538,8 @@
|
|||||||
//#define MIN_BED_POWER 0
|
//#define MIN_BED_POWER 0
|
||||||
//#define PID_BED_DEBUG // Sends debug data to the serial port.
|
//#define PID_BED_DEBUG // Sends debug data to the serial port.
|
||||||
|
|
||||||
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
|
// 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
|
||||||
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
|
// from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
|
||||||
//#define DEFAULT_bedKp 10.00
|
|
||||||
//#define DEFAULT_bedKi .023
|
|
||||||
//#define DEFAULT_bedKd 305.4
|
|
||||||
|
|
||||||
// Wanhao Duplicator i3
|
|
||||||
//#define DEFAULT_bedKp 249.52
|
|
||||||
//#define DEFAULT_bedKi 47.89
|
|
||||||
//#define DEFAULT_bedKd 325.03
|
|
||||||
|
|
||||||
// Defaults from https://www.itsalllost.com/wanhao-i3-32bit-upgrade/
|
|
||||||
//#define DEFAULT_bedKp 602.82
|
|
||||||
//#define DEFAULT_bedKi 114.98
|
|
||||||
//#define DEFAULT_bedKd 790.15
|
|
||||||
|
|
||||||
//120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
|
|
||||||
//from pidautotune
|
|
||||||
//#define DEFAULT_bedKp 97.1
|
|
||||||
//#define DEFAULT_bedKi 1.41
|
|
||||||
//#define DEFAULT_bedKd 1675.16
|
|
||||||
|
|
||||||
// Defaults from PID Tuning
|
|
||||||
#define DEFAULT_bedKp 148.74
|
#define DEFAULT_bedKp 148.74
|
||||||
#define DEFAULT_bedKi 29.72
|
#define DEFAULT_bedKi 29.72
|
||||||
#define DEFAULT_bedKd 496.30
|
#define DEFAULT_bedKd 496.30
|
||||||
@ -643,7 +601,7 @@
|
|||||||
|
|
||||||
// @section machine
|
// @section machine
|
||||||
|
|
||||||
// Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics
|
// Enable one of the options below for CoreXY, CoreXZ, or CoreYZ kinematics,
|
||||||
// either in the usual order or reversed
|
// either in the usual order or reversed
|
||||||
//#define COREXY
|
//#define COREXY
|
||||||
//#define COREXZ
|
//#define COREXZ
|
||||||
@ -651,6 +609,7 @@
|
|||||||
//#define COREYX
|
//#define COREYX
|
||||||
//#define COREZX
|
//#define COREZX
|
||||||
//#define COREZY
|
//#define COREZY
|
||||||
|
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//============================== Endstop Settings ===========================
|
//============================== Endstop Settings ===========================
|
||||||
@ -901,7 +860,6 @@
|
|||||||
* - For simple switches connect...
|
* - For simple switches connect...
|
||||||
* - normally-closed switches to GND and D32.
|
* - normally-closed switches to GND and D32.
|
||||||
* - normally-open switches to 5V and D32.
|
* - normally-open switches to 5V and D32.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
|
//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default
|
||||||
|
|
||||||
@ -1612,7 +1570,6 @@
|
|||||||
*
|
*
|
||||||
* Caveats: The ending Z should be the same as starting Z.
|
* Caveats: The ending Z should be the same as starting Z.
|
||||||
* Attention: EXPERIMENTAL. G-code arguments may change.
|
* Attention: EXPERIMENTAL. G-code arguments may change.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
//#define NOZZLE_CLEAN_FEATURE
|
//#define NOZZLE_CLEAN_FEATURE
|
||||||
|
|
||||||
@ -1765,7 +1722,6 @@
|
|||||||
*
|
*
|
||||||
* SD Card support is disabled by default. If your controller has an SD slot,
|
* SD Card support is disabled by default. If your controller has an SD slot,
|
||||||
* you must uncomment the following option or it won't work.
|
* you must uncomment the following option or it won't work.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define SDSUPPORT
|
#define SDSUPPORT
|
||||||
|
|
||||||
@ -2002,6 +1958,14 @@
|
|||||||
//
|
//
|
||||||
//#define FF_INTERFACEBOARD
|
//#define FF_INTERFACEBOARD
|
||||||
|
|
||||||
|
//
|
||||||
|
// TFT GLCD Panel with Marlin UI
|
||||||
|
// Panel connected to main board by SPI or I2C interface.
|
||||||
|
// See https://github.com/Serhiy-K/TFTGLCDAdapter
|
||||||
|
//
|
||||||
|
//#define TFTGLCD_PANEL_SPI
|
||||||
|
//#define TFTGLCD_PANEL_I2C
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//======================= LCD / Controller Selection =======================
|
//======================= LCD / Controller Selection =======================
|
||||||
//========================= (Graphical LCDs) ========================
|
//========================= (Graphical LCDs) ========================
|
||||||
@ -2209,6 +2173,9 @@
|
|||||||
// Touch-screen LCD for Malyan M200/M300 printers
|
// Touch-screen LCD for Malyan M200/M300 printers
|
||||||
//
|
//
|
||||||
//#define MALYAN_LCD
|
//#define MALYAN_LCD
|
||||||
|
#if ENABLED(MALYAN_LCD)
|
||||||
|
#define LCD_SERIAL_PORT 1 // Default is 1 for Malyan M200
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Touch UI for FTDI EVE (FT800/FT810) displays
|
// Touch UI for FTDI EVE (FT800/FT810) displays
|
||||||
@ -2222,7 +2189,7 @@
|
|||||||
//#define ANYCUBIC_LCD_I3MEGA
|
//#define ANYCUBIC_LCD_I3MEGA
|
||||||
//#define ANYCUBIC_LCD_CHIRON
|
//#define ANYCUBIC_LCD_CHIRON
|
||||||
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
||||||
#define ANYCUBIC_LCD_SERIAL_PORT 3
|
#define LCD_SERIAL_PORT 3 // Default is 3 for Anycubic
|
||||||
//#define ANYCUBIC_LCD_DEBUG
|
//#define ANYCUBIC_LCD_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2381,7 +2348,6 @@
|
|||||||
* *** CAUTION ***
|
* *** CAUTION ***
|
||||||
*
|
*
|
||||||
* LED Type. Enable only one of the following two options.
|
* LED Type. Enable only one of the following two options.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
//#define RGB_LED
|
//#define RGB_LED
|
||||||
//#define RGBW_LED
|
//#define RGBW_LED
|
||||||
|
@ -29,9 +29,8 @@
|
|||||||
* Some of these settings can damage your printer if improperly set!
|
* Some of these settings can damage your printer if improperly set!
|
||||||
*
|
*
|
||||||
* Basic settings can be found in Configuration.h
|
* Basic settings can be found in Configuration.h
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define CONFIGURATION_ADV_H_VERSION 020006
|
#define CONFIGURATION_ADV_H_VERSION 020007
|
||||||
|
|
||||||
// @section temperature
|
// @section temperature
|
||||||
|
|
||||||
@ -738,7 +737,6 @@
|
|||||||
* | 4 3 | 1 4 | 2 1 | 3 2 |
|
* | 4 3 | 1 4 | 2 1 | 3 2 |
|
||||||
* | | | | |
|
* | | | | |
|
||||||
* | 1 2 | 2 3 | 3 4 | 4 1 |
|
* | 1 2 | 2 3 | 3 4 | 4 1 |
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#ifndef Z_STEPPER_ALIGN_XY
|
#ifndef Z_STEPPER_ALIGN_XY
|
||||||
//#define Z_STEPPERS_ORIENTATION 0
|
//#define Z_STEPPERS_ORIENTATION 0
|
||||||
@ -773,7 +771,6 @@
|
|||||||
//
|
//
|
||||||
//#define ASSISTED_TRAMMING
|
//#define ASSISTED_TRAMMING
|
||||||
#if ENABLED(ASSISTED_TRAMMING)
|
#if ENABLED(ASSISTED_TRAMMING)
|
||||||
|
|
||||||
// Define positions for probing points, use the hotend as reference not the sensor.
|
// Define positions for probing points, use the hotend as reference not the sensor.
|
||||||
#define TRAMMING_POINT_XY { { 20, 20 }, { 200, 20 }, { 200, 200 }, { 20, 200 } }
|
#define TRAMMING_POINT_XY { { 20, 20 }, { 200, 20 }, { 200, 200 }, { 20, 200 } }
|
||||||
|
|
||||||
@ -786,6 +783,9 @@
|
|||||||
// Enable to restore leveling setup after operation
|
// Enable to restore leveling setup after operation
|
||||||
#define RESTORE_LEVELING_AFTER_G35
|
#define RESTORE_LEVELING_AFTER_G35
|
||||||
|
|
||||||
|
// Add a menu item for Assisted Tramming
|
||||||
|
//#define ASSISTED_TRAMMING_MENU_ITEM
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Screw thread:
|
* Screw thread:
|
||||||
* M3: 30 = Clockwise, 31 = Counter-Clockwise
|
* M3: 30 = Clockwise, 31 = Counter-Clockwise
|
||||||
@ -793,7 +793,6 @@
|
|||||||
* M5: 50 = Clockwise, 51 = Counter-Clockwise
|
* M5: 50 = Clockwise, 51 = Counter-Clockwise
|
||||||
*/
|
*/
|
||||||
#define TRAMMING_SCREW_THREAD 30
|
#define TRAMMING_SCREW_THREAD 30
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// @section motion
|
// @section motion
|
||||||
@ -1105,16 +1104,18 @@
|
|||||||
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
|
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
|
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
|
||||||
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
|
|
||||||
//#define SHOW_REMAINING_TIME // Display estimated time to completion
|
//#define SHOW_REMAINING_TIME // Display estimated time to completion
|
||||||
#if ENABLED(SHOW_REMAINING_TIME)
|
#if ENABLED(SHOW_REMAINING_TIME)
|
||||||
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
|
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
|
||||||
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
|
//#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
//#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
|
||||||
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
|
//#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing
|
||||||
#if ENABLED(LCD_PROGRESS_BAR)
|
#if ENABLED(LCD_PROGRESS_BAR)
|
||||||
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
|
#define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar
|
||||||
@ -1123,6 +1124,7 @@
|
|||||||
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
|
//#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it
|
||||||
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
|
//#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
@ -1164,6 +1166,7 @@
|
|||||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
|
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
|
||||||
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
|
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
|
||||||
|
//#define POWER_LOSS_RECOVER_ZHOME // Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
|
||||||
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
|
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
|
||||||
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
|
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
|
||||||
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
|
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
|
||||||
@ -1324,7 +1327,7 @@
|
|||||||
* controller events, as there is a trade-off between reliable
|
* controller events, as there is a trade-off between reliable
|
||||||
* printing performance versus fast display updates.
|
* printing performance versus fast display updates.
|
||||||
*/
|
*/
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
// Show SD percentage next to the progress bar
|
// Show SD percentage next to the progress bar
|
||||||
//#define DOGM_SD_PERCENT
|
//#define DOGM_SD_PERCENT
|
||||||
|
|
||||||
@ -1394,18 +1397,18 @@
|
|||||||
//#define MARLIN_SNAKE
|
//#define MARLIN_SNAKE
|
||||||
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
|
//#define GAMES_EASTER_EGG // Add extra blank lines above the "Games" sub-menu
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
//
|
//
|
||||||
// Additional options for DGUS / DWIN displays
|
// Additional options for DGUS / DWIN displays
|
||||||
//
|
//
|
||||||
#if HAS_DGUS_LCD
|
#if HAS_DGUS_LCD
|
||||||
#define DGUS_SERIAL_PORT 3
|
#define LCD_SERIAL_PORT 3
|
||||||
#define DGUS_BAUDRATE 115200
|
#define LCD_BAUDRATE 115200
|
||||||
|
|
||||||
#define DGUS_RX_BUFFER_SIZE 128
|
#define DGUS_RX_BUFFER_SIZE 128
|
||||||
#define DGUS_TX_BUFFER_SIZE 48
|
#define DGUS_TX_BUFFER_SIZE 48
|
||||||
//#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)
|
//#define 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 DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
|
||||||
|
|
||||||
@ -1572,6 +1575,7 @@
|
|||||||
#if ENABLED(BABYSTEPPING)
|
#if ENABLED(BABYSTEPPING)
|
||||||
//#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
|
//#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR
|
||||||
//#define BABYSTEP_WITHOUT_HOMING
|
//#define BABYSTEP_WITHOUT_HOMING
|
||||||
|
//#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
|
||||||
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
|
//#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA!
|
||||||
#define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
|
#define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way
|
||||||
//#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps
|
//#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps
|
||||||
@ -1582,7 +1586,6 @@
|
|||||||
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
|
#if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING)
|
||||||
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
|
#define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds.
|
||||||
// Note: Extra time may be added to mitigate controller latency.
|
// Note: Extra time may be added to mitigate controller latency.
|
||||||
//#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement).
|
|
||||||
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle.
|
//#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle.
|
||||||
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
||||||
#define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size.
|
#define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size.
|
||||||
@ -1950,7 +1953,6 @@
|
|||||||
* Be sure to turn off auto-retract during filament change.
|
* Be sure to turn off auto-retract during filament change.
|
||||||
*
|
*
|
||||||
* Note that M207 / M208 / M209 settings are saved to EEPROM.
|
* Note that M207 / M208 / M209 settings are saved to EEPROM.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
//#define FWRETRACT
|
//#define FWRETRACT
|
||||||
#if ENABLED(FWRETRACT)
|
#if ENABLED(FWRETRACT)
|
||||||
@ -1976,7 +1978,7 @@
|
|||||||
* Universal tool change settings.
|
* Universal tool change settings.
|
||||||
* Applies to all types of extruders except where explicitly noted.
|
* Applies to all types of extruders except where explicitly noted.
|
||||||
*/
|
*/
|
||||||
#if EXTRUDERS > 1
|
#if HAS_MULTI_EXTRUDER
|
||||||
// Z raise distance for tool-change, as needed for some extruders
|
// Z raise distance for tool-change, as needed for some extruders
|
||||||
#define TOOLCHANGE_ZRAISE 2 // (mm)
|
#define TOOLCHANGE_ZRAISE 2 // (mm)
|
||||||
//#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
|
//#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled)
|
||||||
@ -2040,7 +2042,7 @@
|
|||||||
//#define TOOLCHANGE_PARK_X_ONLY // X axis only move
|
//#define TOOLCHANGE_PARK_X_ONLY // X axis only move
|
||||||
//#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move
|
//#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move
|
||||||
#endif
|
#endif
|
||||||
#endif // EXTRUDERS > 1
|
#endif // HAS_MULTI_EXTRUDER
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advanced Pause
|
* Advanced Pause
|
||||||
@ -2487,7 +2489,7 @@
|
|||||||
#define E7_HYBRID_THRESHOLD 30
|
#define E7_HYBRID_THRESHOLD 30
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use StallGuard2 to home / probe X, Y, Z.
|
* Use StallGuard to home / probe X, Y, Z.
|
||||||
*
|
*
|
||||||
* TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
|
* TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
|
||||||
* Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
|
* Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
|
||||||
@ -2508,6 +2510,8 @@
|
|||||||
*
|
*
|
||||||
* IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
|
* IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
|
||||||
* homing and adds a guard period for endstop triggering.
|
* homing and adds a guard period for endstop triggering.
|
||||||
|
*
|
||||||
|
* Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis.
|
||||||
*/
|
*/
|
||||||
#define SENSORLESS_HOMING // StallGuard capable drivers only
|
#define SENSORLESS_HOMING // StallGuard capable drivers only
|
||||||
|
|
||||||
@ -3227,6 +3231,7 @@
|
|||||||
//#define HOST_ACTION_COMMANDS
|
//#define HOST_ACTION_COMMANDS
|
||||||
#if ENABLED(HOST_ACTION_COMMANDS)
|
#if ENABLED(HOST_ACTION_COMMANDS)
|
||||||
//#define HOST_PROMPT_SUPPORT
|
//#define HOST_PROMPT_SUPPORT
|
||||||
|
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3334,6 +3339,7 @@
|
|||||||
#define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max
|
#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_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
|
||||||
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
|
#define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
|
||||||
|
//#define JOYSTICK_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3411,10 +3417,10 @@
|
|||||||
#if ENABLED(PRUSA_MMU2)
|
#if ENABLED(PRUSA_MMU2)
|
||||||
|
|
||||||
// Serial port used for communication with MMU2.
|
// Serial port used for communication with MMU2.
|
||||||
// For AVR enable the UART port used for the MMU. (e.g., internalSerial)
|
// For AVR enable the UART port used for the MMU. (e.g., mmuSerial)
|
||||||
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
|
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
|
||||||
#define INTERNAL_SERIAL_PORT 2
|
#define MMU2_SERIAL_PORT 2
|
||||||
#define MMU2_SERIAL internalSerial
|
#define MMU2_SERIAL mmuSerial
|
||||||
|
|
||||||
// Use hardware reset for MMU if a pin is defined for it
|
// Use hardware reset for MMU if a pin is defined for it
|
||||||
//#define MMU2_RST_PIN 23
|
//#define MMU2_RST_PIN 23
|
||||||
@ -3465,7 +3471,7 @@
|
|||||||
*/
|
*/
|
||||||
//#define MMU_EXTRUDER_SENSOR
|
//#define MMU_EXTRUDER_SENSOR
|
||||||
#if ENABLED(MMU_EXTRUDER_SENSOR)
|
#if ENABLED(MMU_EXTRUDER_SENSOR)
|
||||||
#define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail
|
#define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
108
Marlin/Makefile
108
Marlin/Makefile
@ -170,110 +170,114 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1100)
|
|||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1101)
|
||||||
# Velleman K8400 Controller (derived from 3Drag Controller)
|
# Velleman K8400 Controller (derived from 3Drag Controller)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1102)
|
||||||
# Velleman K8600 Controller (derived from 3Drag Controller)
|
# Velleman K8600 Controller (Vertex Nano)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1103)
|
||||||
# 2PrintBeta BAM&DICE with STK drivers
|
# Velleman K8800 Controller (Vertex Delta)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1104)
|
||||||
# 2PrintBeta BAM&DICE Due with STK drivers
|
# 2PrintBeta BAM&DICE with STK drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1105)
|
||||||
# MKS BASE v1.0
|
# 2PrintBeta BAM&DICE Due with STK drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1106)
|
||||||
# MKS v1.4 with A4982 stepper drivers
|
# MKS BASE v1.0
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1107)
|
||||||
# MKS v1.5 with Allegro A4982 stepper drivers
|
# MKS v1.4 with A4982 stepper drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1108)
|
||||||
# MKS v1.6 with Allegro A4982 stepper drivers
|
# MKS v1.5 with Allegro A4982 stepper drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1109)
|
||||||
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
# MKS v1.6 with Allegro A4982 stepper drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1110)
|
||||||
# MKS GEN v1.3 or 1.4
|
# MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1111)
|
||||||
# MKS GEN L
|
# MKS GEN v1.3 or 1.4
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1112)
|
||||||
# zrib V2.0 control board (Chinese knock off RAMPS replica)
|
# MKS GEN L
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1113)
|
||||||
# BigTreeTech or BIQU KFB2.0
|
# zrib V2.0 control board (Chinese knock off RAMPS replica)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1114)
|
||||||
# Felix 2.0+ Electronics Board (RAMPS like)
|
# BigTreeTech or BIQU KFB2.0
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1115)
|
||||||
# Invent-A-Part RigidBoard
|
# Felix 2.0+ Electronics Board (RAMPS like)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1116)
|
||||||
# Invent-A-Part RigidBoard V2
|
# Invent-A-Part RigidBoard
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1117)
|
||||||
# Sainsmart 2-in-1 board
|
# Invent-A-Part RigidBoard V2
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1118)
|
||||||
# Ultimaker
|
# Sainsmart 2-in-1 board
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1119)
|
||||||
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
# Ultimaker
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1120)
|
||||||
|
# Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||||
|
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
||||||
MCU ?= atmega1280
|
MCU ?= atmega1280
|
||||||
|
|
||||||
# Azteeg X3
|
# Azteeg X3
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1121)
|
|
||||||
# Azteeg X3 Pro
|
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1122)
|
||||||
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
# Azteeg X3 Pro
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1123)
|
||||||
# Rumba
|
# Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1124)
|
||||||
# Raise3D Rumba
|
# Rumba
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1125)
|
||||||
# Rapide Lite RL200 Rumba
|
# Raise3D Rumba
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1126)
|
||||||
# Formbot T-Rex 2 Plus
|
# Rapide Lite RL200 Rumba
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1127)
|
||||||
# Formbot T-Rex 3
|
# Formbot T-Rex 2 Plus
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1128)
|
||||||
# Formbot Raptor
|
# Formbot T-Rex 3
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1129)
|
||||||
# Formbot Raptor 2
|
# Formbot Raptor
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1130)
|
||||||
# bq ZUM Mega 3D
|
# Formbot Raptor 2
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1131)
|
||||||
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
|
# bq ZUM Mega 3D
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1132)
|
||||||
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
|
# MakeBoard Mini v2.1.2 is a control board sold by MicroMake
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1133)
|
||||||
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
|
# TriGorilla Anycubic version 1.3 based on RAMPS EFB
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1134)
|
||||||
# TriGorilla Anycubic version 1.4 Rev 1.1
|
# TriGorilla Anycubic version 1.4 based on RAMPS EFB
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1135)
|
||||||
# Creality: Ender-4, CR-8
|
# TriGorilla Anycubic version 1.4 Rev 1.1
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1136)
|
||||||
# Creality: CR10S, CR20, CR-X
|
# Creality: Ender-4, CR-8
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1137)
|
||||||
# Dagoma F5
|
# Creality: CR10S, CR20, CR-X
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1138)
|
||||||
# FYSETC F6 1.3
|
# Dagoma F5
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1139)
|
||||||
# FYSETC F6 1.5
|
# FYSETC F6 1.3
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1140)
|
||||||
# Duplicator i3 Plus
|
# FYSETC F6 1.5
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1141)
|
||||||
# VORON
|
# Duplicator i3 Plus
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1142)
|
||||||
# TRONXY V3 1.0
|
# VORON
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1143)
|
||||||
# Z-Bolt X Series
|
# TRONXY V3 1.0
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1144)
|
||||||
# TT OSCAR
|
# Z-Bolt X Series
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1145)
|
||||||
# Overlord/Overlord Pro
|
# TT OSCAR
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1146)
|
||||||
# ADIMLab Gantry v1
|
# Overlord/Overlord Pro
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1147)
|
||||||
# ADIMLab Gantry v2
|
# ADIMLab Gantry v1
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1148)
|
||||||
# BIQU Tango V1
|
# ADIMLab Gantry v2
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1149)
|
||||||
# MKS GEN L V2
|
# BIQU Tango V1
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1150)
|
||||||
# Copymaster 3D
|
# MKS GEN L V2
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1151)
|
||||||
# Ortur 4
|
# MKS GEN L V2.1
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1152)
|
||||||
# Tenlog D3 Hero
|
# Copymaster 3D
|
||||||
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
|
else ifeq ($(HARDWARE_MOTHERBOARD),1153)
|
||||||
|
# Ortur 4
|
||||||
|
else ifeq ($(HARDWARE_MOTHERBOARD),1154)
|
||||||
|
# Tenlog D3 Hero
|
||||||
|
else ifeq ($(HARDWARE_MOTHERBOARD),1155)
|
||||||
|
|
||||||
#
|
#
|
||||||
# RAMBo and derivatives
|
# RAMBo and derivatives
|
||||||
@ -694,7 +698,7 @@ ifeq ($(HARDWARE_VARIANT), Teensy)
|
|||||||
LIB_CXXSRC += usb_api.cpp
|
LIB_CXXSRC += usb_api.cpp
|
||||||
|
|
||||||
else ifeq ($(HARDWARE_VARIANT), archim)
|
else ifeq ($(HARDWARE_VARIANT), archim)
|
||||||
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
|
CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
|
||||||
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
|
LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
|
||||||
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
|
LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/**
|
/**
|
||||||
* Marlin release version identifier
|
* Marlin release version identifier
|
||||||
*/
|
*/
|
||||||
//#define SHORT_BUILD_VERSION "2.0.6.1"
|
//#define SHORT_BUILD_VERSION "2.0.7"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbose version identifier which should contain a reference to the location
|
* Verbose version identifier which should contain a reference to the location
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -81,54 +82,29 @@ typedef int8_t pin_t;
|
|||||||
|
|
||||||
// Serial ports
|
// Serial ports
|
||||||
#ifdef USBCON
|
#ifdef USBCON
|
||||||
#if ENABLED(BLUETOOTH)
|
#define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial)
|
||||||
#define MYSERIAL0 bluetoothSerial
|
|
||||||
#else
|
|
||||||
#define MYSERIAL0 Serial
|
|
||||||
#endif
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#else
|
#else
|
||||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MYSERIAL0 customizedSerial1
|
#define MYSERIAL0 customizedSerial1
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#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. Please update your configuration."
|
|
||||||
#endif
|
#endif
|
||||||
#define MYSERIAL1 customizedSerial2
|
#define MYSERIAL1 customizedSerial2
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
|
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "LCD_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
|
#endif
|
||||||
#define DGUS_SERIAL internalDgusSerial
|
#define LCD_SERIAL lcdSerial
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
|
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ANYCUBIC_LCD_SERIAL_PORT
|
|
||||||
#if !WITHIN(ANYCUBIC_LCD_SERIAL_PORT, -1, 3)
|
|
||||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
|
||||||
#elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT
|
|
||||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
|
||||||
#elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2
|
|
||||||
#error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
|
||||||
#endif
|
#endif
|
||||||
#define ANYCUBIC_LCD_SERIAL anycubicLcdSerial
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
@ -40,32 +40,32 @@
|
|||||||
|
|
||||||
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
|
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
|
||||||
|
|
||||||
#include "MarlinSerial.h"
|
#include "MarlinSerial.h"
|
||||||
#include "../../MarlinCore.h"
|
#include "../../MarlinCore.h"
|
||||||
|
|
||||||
#if ENABLED(DIRECT_STEPPING)
|
#if ENABLED(DIRECT_STEPPING)
|
||||||
#include "../../feature/direct_stepping.h"
|
#include "../../feature/direct_stepping.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
|
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 };
|
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };
|
||||||
template<typename Cfg> bool MarlinSerial<Cfg>::_written = false;
|
template<typename Cfg> bool MarlinSerial<Cfg>::_written = false;
|
||||||
template<typename Cfg> uint8_t MarlinSerial<Cfg>::xon_xoff_state = MarlinSerial<Cfg>::XON_XOFF_CHAR_SENT | MarlinSerial<Cfg>::XON_CHAR;
|
template<typename Cfg> uint8_t MarlinSerial<Cfg>::xon_xoff_state = MarlinSerial<Cfg>::XON_XOFF_CHAR_SENT | MarlinSerial<Cfg>::XON_CHAR;
|
||||||
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_dropped_bytes = 0;
|
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_dropped_bytes = 0;
|
||||||
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_buffer_overruns = 0;
|
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_buffer_overruns = 0;
|
||||||
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_framing_errors = 0;
|
template<typename Cfg> uint8_t MarlinSerial<Cfg>::rx_framing_errors = 0;
|
||||||
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::rx_max_enqueued = 0;
|
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::rx_max_enqueued = 0;
|
||||||
|
|
||||||
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
||||||
#define sw_barrier() asm volatile("": : :"memory");
|
#define sw_barrier() asm volatile("": : :"memory");
|
||||||
|
|
||||||
#include "../../feature/e_parser.h"
|
#include "../../feature/e_parser.h"
|
||||||
|
|
||||||
// "Atomically" read the RX head index value without disabling interrupts:
|
// "Atomically" read the RX head index value without disabling interrupts:
|
||||||
// This MUST be called with RX interrupts enabled, and CAN'T be called
|
// This MUST be called with RX interrupts enabled, and CAN'T be called
|
||||||
// from the RX ISR itself!
|
// from the RX ISR itself!
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
FORCE_INLINE typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::atomic_read_rx_head() {
|
FORCE_INLINE typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::atomic_read_rx_head() {
|
||||||
if (Cfg::RX_SIZE > 256) {
|
if (Cfg::RX_SIZE > 256) {
|
||||||
// Keep reading until 2 consecutive reads return the same value,
|
// Keep reading until 2 consecutive reads return the same value,
|
||||||
// meaning there was no update in-between caused by an interrupt.
|
// meaning there was no update in-between caused by an interrupt.
|
||||||
@ -85,19 +85,19 @@
|
|||||||
// With an 8bit index, reads are always atomic. No need for special handling
|
// With an 8bit index, reads are always atomic. No need for special handling
|
||||||
return rx_buffer.head;
|
return rx_buffer.head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
volatile bool MarlinSerial<Cfg>::rx_tail_value_not_stable = false;
|
volatile bool MarlinSerial<Cfg>::rx_tail_value_not_stable = false;
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
volatile uint16_t MarlinSerial<Cfg>::rx_tail_value_backup = 0;
|
volatile uint16_t MarlinSerial<Cfg>::rx_tail_value_backup = 0;
|
||||||
|
|
||||||
// Set RX tail index, taking into account the RX ISR could interrupt
|
// Set RX tail index, taking into account the RX ISR could interrupt
|
||||||
// the write to this variable in the middle - So a backup strategy
|
// the write to this variable in the middle - So a backup strategy
|
||||||
// is used to ensure reads of the correct values.
|
// is used to ensure reads of the correct values.
|
||||||
// -Must NOT be called from the RX ISR -
|
// -Must NOT be called from the RX ISR -
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
FORCE_INLINE void MarlinSerial<Cfg>::atomic_set_rx_tail(typename MarlinSerial<Cfg>::ring_buffer_pos_t value) {
|
FORCE_INLINE void MarlinSerial<Cfg>::atomic_set_rx_tail(typename MarlinSerial<Cfg>::ring_buffer_pos_t value) {
|
||||||
if (Cfg::RX_SIZE > 256) {
|
if (Cfg::RX_SIZE > 256) {
|
||||||
// Store the new value in the backup
|
// Store the new value in the backup
|
||||||
rx_tail_value_backup = value;
|
rx_tail_value_backup = value;
|
||||||
@ -114,24 +114,24 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
rx_buffer.tail = value;
|
rx_buffer.tail = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the RX tail index, taking into account the read could be
|
// Get the RX tail index, taking into account the read could be
|
||||||
// interrupting in the middle of the update of that index value
|
// interrupting in the middle of the update of that index value
|
||||||
// -Called from the RX ISR -
|
// -Called from the RX ISR -
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
FORCE_INLINE typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::atomic_read_rx_tail() {
|
FORCE_INLINE typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::atomic_read_rx_tail() {
|
||||||
if (Cfg::RX_SIZE > 256) {
|
if (Cfg::RX_SIZE > 256) {
|
||||||
// If the true index is being modified, return the backup value
|
// If the true index is being modified, return the backup value
|
||||||
if (rx_tail_value_not_stable) return rx_tail_value_backup;
|
if (rx_tail_value_not_stable) return rx_tail_value_backup;
|
||||||
}
|
}
|
||||||
// The true index is stable, return it
|
// The true index is stable, return it
|
||||||
return rx_buffer.tail;
|
return rx_buffer.tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (called with RX interrupts disabled)
|
// (called with RX interrupts disabled)
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
FORCE_INLINE void MarlinSerial<Cfg>::store_rxd_char() {
|
FORCE_INLINE void MarlinSerial<Cfg>::store_rxd_char() {
|
||||||
|
|
||||||
static EmergencyParser::State emergency_state; // = EP_RESET
|
static EmergencyParser::State emergency_state; // = EP_RESET
|
||||||
|
|
||||||
@ -275,11 +275,11 @@
|
|||||||
|
|
||||||
// Store the new head value - The main loop will retry until the value is stable
|
// Store the new head value - The main loop will retry until the value is stable
|
||||||
rx_buffer.head = h;
|
rx_buffer.head = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (called with TX irqs disabled)
|
// (called with TX irqs disabled)
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
FORCE_INLINE void MarlinSerial<Cfg>::_tx_udr_empty_irq() {
|
FORCE_INLINE void MarlinSerial<Cfg>::_tx_udr_empty_irq() {
|
||||||
if (Cfg::TX_SIZE > 0) {
|
if (Cfg::TX_SIZE > 0) {
|
||||||
// Read positions
|
// Read positions
|
||||||
uint8_t t = tx_buffer.tail;
|
uint8_t t = tx_buffer.tail;
|
||||||
@ -328,11 +328,11 @@
|
|||||||
// Disable interrupts if there is nothing to transmit following this byte
|
// Disable interrupts if there is nothing to transmit following this byte
|
||||||
if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
|
if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public Methods
|
// Public Methods
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::begin(const long baud) {
|
void MarlinSerial<Cfg>::begin(const long baud) {
|
||||||
uint16_t baud_setting;
|
uint16_t baud_setting;
|
||||||
bool useU2X = true;
|
bool useU2X = true;
|
||||||
|
|
||||||
@ -360,24 +360,24 @@
|
|||||||
B_RXCIE = 1;
|
B_RXCIE = 1;
|
||||||
if (Cfg::TX_SIZE > 0) B_UDRIE = 0;
|
if (Cfg::TX_SIZE > 0) B_UDRIE = 0;
|
||||||
_written = false;
|
_written = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::end() {
|
void MarlinSerial<Cfg>::end() {
|
||||||
B_RXEN = 0;
|
B_RXEN = 0;
|
||||||
B_TXEN = 0;
|
B_TXEN = 0;
|
||||||
B_RXCIE = 0;
|
B_RXCIE = 0;
|
||||||
B_UDRIE = 0;
|
B_UDRIE = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
int MarlinSerial<Cfg>::peek() {
|
int MarlinSerial<Cfg>::peek() {
|
||||||
const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
|
const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
|
||||||
return h == t ? -1 : rx_buffer.buffer[t];
|
return h == t ? -1 : rx_buffer.buffer[t];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
int MarlinSerial<Cfg>::read() {
|
int MarlinSerial<Cfg>::read() {
|
||||||
const ring_buffer_pos_t h = atomic_read_rx_head();
|
const ring_buffer_pos_t h = atomic_read_rx_head();
|
||||||
|
|
||||||
// Read the tail. Main thread owns it, so it is safe to directly read it
|
// Read the tail. Main thread owns it, so it is safe to directly read it
|
||||||
@ -417,16 +417,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::available() {
|
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::available() {
|
||||||
const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
|
const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail;
|
||||||
return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1);
|
return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::flush() {
|
void MarlinSerial<Cfg>::flush() {
|
||||||
|
|
||||||
// Set the tail to the head:
|
// Set the tail to the head:
|
||||||
// - Read the RX head index in a safe way. (See atomic_read_rx_head.)
|
// - Read the RX head index in a safe way. (See atomic_read_rx_head.)
|
||||||
@ -451,10 +451,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::write(const uint8_t c) {
|
void MarlinSerial<Cfg>::write(const uint8_t c) {
|
||||||
if (Cfg::TX_SIZE == 0) {
|
if (Cfg::TX_SIZE == 0) {
|
||||||
|
|
||||||
_written = true;
|
_written = true;
|
||||||
@ -510,10 +510,10 @@
|
|||||||
// Enable TX ISR - Non atomic, but it will eventually enable TX ISR
|
// Enable TX ISR - Non atomic, but it will eventually enable TX ISR
|
||||||
B_UDRIE = 1;
|
B_UDRIE = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::flushTX() {
|
void MarlinSerial<Cfg>::flushTX() {
|
||||||
|
|
||||||
if (Cfg::TX_SIZE == 0) {
|
if (Cfg::TX_SIZE == 0) {
|
||||||
// No bytes written, no need to flush. This special case is needed since there's
|
// No bytes written, no need to flush. This special case is needed since there's
|
||||||
@ -554,34 +554,34 @@
|
|||||||
// At this point nothing is queued anymore (DRIE is disabled) and
|
// At this point nothing is queued anymore (DRIE is disabled) and
|
||||||
// the hardware finished transmission (TXC is set).
|
// the hardware finished transmission (TXC is set).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports from print.h
|
* Imports from print.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(char c, int base) {
|
void MarlinSerial<Cfg>::print(char c, int base) {
|
||||||
print((long)c, base);
|
print((long)c, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(unsigned char b, int base) {
|
void MarlinSerial<Cfg>::print(unsigned char b, int base) {
|
||||||
print((unsigned long)b, base);
|
print((unsigned long)b, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(int n, int base) {
|
void MarlinSerial<Cfg>::print(int n, int base) {
|
||||||
print((long)n, base);
|
print((long)n, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(unsigned int n, int base) {
|
void MarlinSerial<Cfg>::print(unsigned int n, int base) {
|
||||||
print((unsigned long)n, base);
|
print((unsigned long)n, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(long n, int base) {
|
void MarlinSerial<Cfg>::print(long n, int base) {
|
||||||
if (base == 0) write(n);
|
if (base == 0) write(n);
|
||||||
else if (base == 10) {
|
else if (base == 10) {
|
||||||
if (n < 0) { print('-'); n = -n; }
|
if (n < 0) { print('-'); n = -n; }
|
||||||
@ -589,83 +589,83 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
printNumber(n, base);
|
printNumber(n, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(unsigned long n, int base) {
|
void MarlinSerial<Cfg>::print(unsigned long n, int base) {
|
||||||
if (base == 0) write(n);
|
if (base == 0) write(n);
|
||||||
else printNumber(n, base);
|
else printNumber(n, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::print(double n, int digits) {
|
void MarlinSerial<Cfg>::print(double n, int digits) {
|
||||||
printFloat(n, digits);
|
printFloat(n, digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println() {
|
void MarlinSerial<Cfg>::println() {
|
||||||
print('\r');
|
print('\r');
|
||||||
print('\n');
|
print('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(const String& s) {
|
void MarlinSerial<Cfg>::println(const String& s) {
|
||||||
print(s);
|
print(s);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(const char c[]) {
|
void MarlinSerial<Cfg>::println(const char c[]) {
|
||||||
print(c);
|
print(c);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(char c, int base) {
|
void MarlinSerial<Cfg>::println(char c, int base) {
|
||||||
print(c, base);
|
print(c, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(unsigned char b, int base) {
|
void MarlinSerial<Cfg>::println(unsigned char b, int base) {
|
||||||
print(b, base);
|
print(b, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(int n, int base) {
|
void MarlinSerial<Cfg>::println(int n, int base) {
|
||||||
print(n, base);
|
print(n, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(unsigned int n, int base) {
|
void MarlinSerial<Cfg>::println(unsigned int n, int base) {
|
||||||
print(n, base);
|
print(n, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(long n, int base) {
|
void MarlinSerial<Cfg>::println(long n, int base) {
|
||||||
print(n, base);
|
print(n, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(unsigned long n, int base) {
|
void MarlinSerial<Cfg>::println(unsigned long n, int base) {
|
||||||
print(n, base);
|
print(n, base);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::println(double n, int digits) {
|
void MarlinSerial<Cfg>::println(double n, int digits) {
|
||||||
print(n, digits);
|
print(n, digits);
|
||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private Methods
|
// Private Methods
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::printNumber(unsigned long n, uint8_t base) {
|
void MarlinSerial<Cfg>::printNumber(unsigned long n, uint8_t base) {
|
||||||
if (n) {
|
if (n) {
|
||||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
||||||
int8_t i = 0;
|
int8_t i = 0;
|
||||||
@ -678,10 +678,10 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
print('0');
|
print('0');
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
|
void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
|
||||||
// Handle negative numbers
|
// Handle negative numbers
|
||||||
if (number < 0.0) {
|
if (number < 0.0) {
|
||||||
print('-');
|
print('-');
|
||||||
@ -709,31 +709,31 @@
|
|||||||
remainder -= toPrint;
|
remainder -= toPrint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hookup ISR handlers
|
// Hookup ISR handlers
|
||||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)) {
|
ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) {
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::store_rxd_char();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::store_rxd_char();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_UDRE_vect)) {
|
ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) {
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::_tx_udr_empty_irq();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
// Preinstantiate
|
||||||
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;
|
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;
|
||||||
|
|
||||||
// Instantiate
|
// Instantiate
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
|
|
||||||
// Hookup ISR handlers
|
// Hookup ISR handlers
|
||||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_RX_vect)) {
|
ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _RX_vect)) {
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::store_rxd_char();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::store_rxd_char();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_UDRE_vect)) {
|
ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _UDRE_vect)) {
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::_tx_udr_empty_irq();
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,30 +743,43 @@
|
|||||||
// Instantiate
|
// Instantiate
|
||||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
|
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
#ifdef MMU2_SERIAL_PORT
|
||||||
|
|
||||||
#ifdef INTERNAL_SERIAL_PORT
|
ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _RX_vect)) {
|
||||||
|
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::store_rxd_char();
|
||||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) {
|
|
||||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::store_rxd_char();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) {
|
ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _UDRE_vect)) {
|
||||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>::_tx_udr_empty_irq();
|
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preinstantiate
|
// Preinstantiate
|
||||||
template class MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>>;
|
template class MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>;
|
||||||
|
|
||||||
// Instantiate
|
// Instantiate
|
||||||
MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
|
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
|
|
||||||
|
ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _RX_vect)) {
|
||||||
|
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>::store_rxd_char();
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _UDRE_vect)) {
|
||||||
|
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>::_tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preinstantiate
|
||||||
|
template class MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>>;
|
||||||
|
|
||||||
|
// Instantiate
|
||||||
|
MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
||||||
|
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
template<typename Cfg>
|
template<typename Cfg>
|
||||||
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
|
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.
|
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
|
||||||
@ -775,40 +788,11 @@
|
|||||||
if (ret < 0) ret += Cfg::TX_SIZE + 1;
|
if (ret < 0) ret += Cfg::TX_SIZE + 1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
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
|
#endif
|
||||||
|
|
||||||
#ifdef ANYCUBIC_LCD_SERIAL_PORT
|
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
||||||
|
|
||||||
ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_RX_vect)) {
|
|
||||||
MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>>::store_rxd_char();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_UDRE_vect)) {
|
|
||||||
MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>>::_tx_udr_empty_irq();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preinstantiate
|
|
||||||
template class MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>>;
|
|
||||||
|
|
||||||
// Instantiate
|
|
||||||
MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>> anycubicLcdSerial;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For AT90USB targets use the UART for BT interfacing
|
// For AT90USB targets use the UART for BT interfacing
|
||||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||||
|
@ -48,11 +48,11 @@
|
|||||||
|
|
||||||
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
|
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
|
||||||
// requires two levels of indirection to expand macro values properly)
|
// requires two levels of indirection to expand macro values properly)
|
||||||
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
|
#define SERIAL_REGNAME(registerbase,number,suffix) _SERIAL_REGNAME(registerbase,number,suffix)
|
||||||
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
|
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
|
||||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##suffix
|
||||||
#else
|
#else
|
||||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
#define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##number##suffix
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Registers used by MarlinSerial class (expanded depending on selected serial port)
|
// Registers used by MarlinSerial class (expanded depending on selected serial port)
|
||||||
@ -217,10 +217,12 @@
|
|||||||
static ring_buffer_pos_t available();
|
static ring_buffer_pos_t available();
|
||||||
static void write(const uint8_t c);
|
static void write(const uint8_t c);
|
||||||
static void flushTX();
|
static void flushTX();
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#if HAS_DGUS_LCD
|
||||||
static ring_buffer_pos_t get_tx_buffer_free();
|
static ring_buffer_pos_t get_tx_buffer_free();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
||||||
|
|
||||||
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
|
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; }
|
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
||||||
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
||||||
@ -278,55 +280,50 @@
|
|||||||
|
|
||||||
#endif // !USBCON
|
#endif // !USBCON
|
||||||
|
|
||||||
#ifdef INTERNAL_SERIAL_PORT
|
#ifdef MMU2_SERIAL_PORT
|
||||||
template <uint8_t serial>
|
template <uint8_t serial>
|
||||||
struct MarlinInternalSerialCfg {
|
struct MMU2SerialCfg {
|
||||||
static constexpr int PORT = serial;
|
static constexpr int PORT = serial;
|
||||||
|
static constexpr bool XONOFF = false;
|
||||||
|
static constexpr bool EMERGENCYPARSER = false;
|
||||||
|
static constexpr bool DROPPED_RX = false;
|
||||||
|
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||||
|
static constexpr bool MAX_RX_QUEUED = false;
|
||||||
static constexpr unsigned int RX_SIZE = 32;
|
static constexpr unsigned int RX_SIZE = 32;
|
||||||
static constexpr unsigned int TX_SIZE = 32;
|
static constexpr unsigned int TX_SIZE = 32;
|
||||||
static constexpr bool XONOFF = false;
|
|
||||||
static constexpr bool EMERGENCYPARSER = false;
|
|
||||||
static constexpr bool DROPPED_RX = false;
|
|
||||||
static constexpr bool RX_OVERRUNS = false;
|
static constexpr bool RX_OVERRUNS = false;
|
||||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
|
||||||
static constexpr bool MAX_RX_QUEUED = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
|
extern MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>> mmuSerial;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
|
|
||||||
template <uint8_t serial>
|
template <uint8_t serial>
|
||||||
struct MarlinInternalSerialCfg {
|
struct LCDSerialCfg {
|
||||||
static constexpr int PORT = serial;
|
static constexpr int PORT = serial;
|
||||||
|
static constexpr bool XONOFF = false;
|
||||||
|
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
|
||||||
|
static constexpr bool DROPPED_RX = false;
|
||||||
|
static constexpr bool RX_FRAMING_ERRORS = false;
|
||||||
|
static constexpr bool MAX_RX_QUEUED = false;
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
||||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||||
static constexpr bool XONOFF = false;
|
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||||
static constexpr bool EMERGENCYPARSER = false;
|
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
||||||
static constexpr bool DROPPED_RX = false;
|
|
||||||
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, DGUS_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
|
|
||||||
|
|
||||||
#ifdef ANYCUBIC_LCD_SERIAL_PORT
|
|
||||||
template <uint8_t serial>
|
|
||||||
struct AnycubicLcdSerialCfg {
|
|
||||||
static constexpr int PORT = serial;
|
|
||||||
static constexpr unsigned int RX_SIZE = 64;
|
static constexpr unsigned int RX_SIZE = 64;
|
||||||
static constexpr unsigned int TX_SIZE = 128;
|
static constexpr unsigned int TX_SIZE = 128;
|
||||||
static constexpr bool XONOFF = false;
|
|
||||||
static constexpr bool EMERGENCYPARSER = false;
|
|
||||||
static constexpr bool DROPPED_RX = false;
|
|
||||||
static constexpr bool RX_OVERRUNS = false;
|
static constexpr bool RX_OVERRUNS = false;
|
||||||
static constexpr bool RX_FRAMING_ERRORS = false;
|
#else
|
||||||
static constexpr bool MAX_RX_QUEUED = false;
|
static constexpr unsigned int RX_SIZE = 64;
|
||||||
|
static constexpr unsigned int TX_SIZE = 128;
|
||||||
|
static constexpr bool RX_OVERRUNS = false
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>> anycubicLcdSerial;
|
extern MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use the UART for Bluetooth in AT90USB configurations
|
// Use the UART for Bluetooth in AT90USB configurations
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
* readMicroseconds() - Get the last-written servo pulse width in microseconds.
|
* readMicroseconds() - Get the last-written servo pulse width in microseconds.
|
||||||
* attached() - Return true if a servo is attached.
|
* attached() - Return true if a servo is attached.
|
||||||
* detach() - Stop an attached servo from pulsing its i/o pin.
|
* detach() - Stop an attached servo from pulsing its i/o pin.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __AVR__
|
#ifdef __AVR__
|
||||||
|
@ -29,11 +29,17 @@
|
|||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)
|
||||||
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
|
#define AVR_AT90USB1286_FAMILY 1
|
||||||
#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
|
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)
|
||||||
#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
|
#define AVR_ATmega1284_FAMILY 1
|
||||||
#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__))
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
#define AVR_ATmega2560_FAMILY 1
|
||||||
|
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||||
|
#define AVR_ATmega2561_FAMILY 1
|
||||||
|
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
|
||||||
|
#define AVR_ATmega328_FAMILY 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include Ports and Functions
|
* Include Ports and Functions
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
|
|
||||||
#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H)
|
#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
|
||||||
|
#define AVR_ATmega2560_FAMILY_PLUS_70 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if AVR_AT90USB1286_FAMILY
|
#if AVR_AT90USB1286_FAMILY
|
||||||
|
|
||||||
|
@ -22,15 +22,12 @@
|
|||||||
* Structures for 2560 family boards that use more than 70 pins
|
* Structures for 2560 family boards that use more than 70 pins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#undef NUM_DIGITAL_PINS
|
#if MB(BQ_ZUM_MEGA_3D, MINIRAMBO, SCOOVO_X9H, TRIGORILLA_14)
|
||||||
#if MB(BQ_ZUM_MEGA_3D)
|
#undef NUM_DIGITAL_PINS
|
||||||
#define NUM_DIGITAL_PINS 85
|
#define NUM_DIGITAL_PINS 85
|
||||||
#elif MB(MIGHTYBOARD_REVE)
|
#elif MB(MIGHTYBOARD_REVE)
|
||||||
|
#undef NUM_DIGITAL_PINS
|
||||||
#define NUM_DIGITAL_PINS 80
|
#define NUM_DIGITAL_PINS 80
|
||||||
#elif MB(MINIRAMBO)
|
|
||||||
#define NUM_DIGITAL_PINS 85
|
|
||||||
#elif MB(SCOOVO_X9H)
|
|
||||||
#define NUM_DIGITAL_PINS 85
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PA 1
|
#define PA 1
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include "../shared/Marduino.h"
|
#include "../shared/Marduino.h"
|
||||||
#include "../shared/Delay.h"
|
#include "../shared/Delay.h"
|
||||||
@ -189,5 +189,5 @@ uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
#endif // ARDUINO_ARCH_SAM
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
@ -38,59 +38,36 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define _MSERIAL(X) Serial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define Serial0 Serial
|
||||||
|
|
||||||
// Define MYSERIAL0/1 before MarlinSerial includes!
|
// Define MYSERIAL0/1 before MarlinSerial includes!
|
||||||
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
||||||
#define MYSERIAL0 customizedSerial1
|
#define MYSERIAL0 customizedSerial1
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 Serial
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 Serial1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 Serial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 Serial3
|
|
||||||
#else
|
#else
|
||||||
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
#if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||||
#error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
|
|
||||||
#elif SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER)
|
|
||||||
#define MYSERIAL1 customizedSerial2
|
#define MYSERIAL1 customizedSerial2
|
||||||
#elif SERIAL_PORT_2 == 0
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 Serial
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 1
|
|
||||||
#define MYSERIAL1 Serial1
|
|
||||||
#elif SERIAL_PORT_2 == 2
|
|
||||||
#define MYSERIAL1 Serial2
|
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 Serial3
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
#if LCD_SERIAL_PORT == -1
|
||||||
#error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
|
#define LCD_SERIAL lcdSerial
|
||||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#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
|
#else
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@
|
|||||||
SPI_Enable(SPI0);
|
SPI_Enable(SPI0);
|
||||||
|
|
||||||
SET_OUTPUT(DAC0_SYNC);
|
SET_OUTPUT(DAC0_SYNC);
|
||||||
#if EXTRUDERS > 1
|
#if HAS_MULTI_EXTRUDER
|
||||||
SET_OUTPUT(DAC1_SYNC);
|
SET_OUTPUT(DAC1_SYNC);
|
||||||
WRITE(DAC1_SYNC, HIGH);
|
WRITE(DAC1_SYNC, HIGH);
|
||||||
#endif
|
#endif
|
||||||
@ -759,7 +759,6 @@
|
|||||||
*
|
*
|
||||||
* All of the above can be avoided by defining FORCE_SOFT_SPI to force the
|
* All of the above can be avoided by defining FORCE_SOFT_SPI to force the
|
||||||
* display to use software SPI.
|
* display to use software SPI.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)
|
void spiInit(uint8_t spiRate=6) { // Default to slowest rate if not specified)
|
||||||
|
@ -122,6 +122,8 @@ public:
|
|||||||
static void write(const uint8_t c);
|
static void write(const uint8_t c);
|
||||||
static void flushTX();
|
static void flushTX();
|
||||||
|
|
||||||
|
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
|
||||||
|
|
||||||
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
|
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; }
|
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
|
||||||
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; }
|
||||||
|
@ -52,14 +52,13 @@
|
|||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __SAM3X8E__
|
#ifdef __SAM3X8E__
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
|
|
||||||
@ -145,6 +144,6 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#endif //__SAM3X8E__
|
#endif // __SAM3X8E__
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
|
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||||
|
|
||||||
#undef SPI_SPEED
|
#undef SPI_SPEED
|
||||||
#define SPI_SPEED 2 // About 2 MHz
|
#define SPI_SPEED 2 // About 2 MHz
|
||||||
@ -144,5 +144,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
|
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||||
#endif // ARDUINO_ARCH_SAM
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include "../../shared/Delay.h"
|
#include "../../shared/Delay.h"
|
||||||
|
|
||||||
@ -108,5 +108,5 @@ void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
#endif // ARDUINO_ARCH_SAM
|
#endif // ARDUINO_ARCH_SAM
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
* per page. We can't emulate EE endurance with FLASH for all
|
* per page. We can't emulate EE endurance with FLASH for all
|
||||||
* bytes, but we can emulate endurance for a given percent of
|
* bytes, but we can emulate endurance for a given percent of
|
||||||
* bytes.
|
* bytes.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define EE_EMU_DEBUG
|
//#define EE_EMU_DEBUG
|
||||||
|
@ -179,5 +179,4 @@ void pwm_details(int32_t pin) {
|
|||||||
* ----------------+--------
|
* ----------------+--------
|
||||||
* ID | PB11
|
* ID | PB11
|
||||||
* VBOF | PB10
|
* VBOF | PB10
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@ -1112,8 +1112,7 @@ static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
|
|||||||
uint8_t u8[8];
|
uint8_t u8[8];
|
||||||
}long_addr;
|
}long_addr;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
for (index = 0; index < 4; index++)
|
for (index = 0; index < 4; index++) {
|
||||||
{
|
|
||||||
long_addr.u8[index] = *data++;
|
long_addr.u8[index] = *data++;
|
||||||
}
|
}
|
||||||
return long_addr.u32;
|
return long_addr.u32;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -58,9 +59,6 @@ extern portMUX_TYPE spinlock;
|
|||||||
#else
|
#else
|
||||||
#define MYSERIAL1 webSocketSerial
|
#define MYSERIAL1 webSocketSerial
|
||||||
#endif
|
#endif
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
|
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
|
||||||
|
@ -86,7 +86,7 @@ int RingBuffer::read() {
|
|||||||
ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
|
ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) {
|
||||||
ring_buffer_pos_t len = available();
|
ring_buffer_pos_t len = available();
|
||||||
|
|
||||||
for(ring_buffer_pos_t i = 0; read_index != write_index; i++) {
|
for (ring_buffer_pos_t i = 0; read_index != write_index; i++) {
|
||||||
buffer[i] = data[read_index];
|
buffer[i] = data[read_index];
|
||||||
read_index = NEXT_INDEX(read_index, size);
|
read_index = NEXT_INDEX(read_index, size);
|
||||||
}
|
}
|
||||||
@ -139,9 +139,8 @@ size_t WebSocketSerial::write(const uint8_t c) {
|
|||||||
|
|
||||||
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
|
size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) {
|
||||||
size_t written = 0;
|
size_t written = 0;
|
||||||
for(size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++)
|
||||||
written += write(buffer[i]);
|
written += write(buffer[i]);
|
||||||
}
|
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
|
|
||||||
#include HAL_PATH(.,HAL.h)
|
#include HAL_PATH(.,HAL.h)
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_2
|
||||||
|
#define NUM_SERIAL 2
|
||||||
|
#else
|
||||||
|
#define NUM_SERIAL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
|
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
|
||||||
|
|
||||||
#ifndef I2C_ADDRESS
|
#ifndef I2C_ADDRESS
|
||||||
|
@ -62,7 +62,6 @@ uint8_t _getc();
|
|||||||
|
|
||||||
extern HalSerial usb_serial;
|
extern HalSerial usb_serial;
|
||||||
#define MYSERIAL0 usb_serial
|
#define MYSERIAL0 usb_serial
|
||||||
#define NUM_SERIAL 1
|
|
||||||
|
|
||||||
#define ST7920_DELAY_1 DELAY_NS(600)
|
#define ST7920_DELAY_1 DELAY_NS(600)
|
||||||
#define ST7920_DELAY_2 DELAY_NS(750)
|
#define ST7920_DELAY_2 DELAY_NS(750)
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
* Generic RingBuffer
|
* Generic RingBuffer
|
||||||
* T type of the buffer array
|
* T type of the buffer array
|
||||||
* S size of the buffer (must be power of 2)
|
* S size of the buffer (must be power of 2)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
template <typename T, uint32_t S> class RingBuffer {
|
template <typename T, uint32_t S> class RingBuffer {
|
||||||
public:
|
public:
|
||||||
@ -79,6 +78,7 @@ public:
|
|||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
EmergencyParser::State emergency_state;
|
EmergencyParser::State emergency_state;
|
||||||
|
static inline bool emergency_parser_enabled() { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HalSerial() { host_connected = true; }
|
HalSerial() { host_connected = true; }
|
||||||
|
@ -107,7 +107,7 @@ int main() {
|
|||||||
std::thread write_serial (write_serial_thread);
|
std::thread write_serial (write_serial_thread);
|
||||||
std::thread read_serial (read_serial_thread);
|
std::thread read_serial (read_serial_thread);
|
||||||
|
|
||||||
#if NUM_SERIAL > 0
|
#ifdef MYSERIAL0
|
||||||
MYSERIAL0.begin(BAUDRATE);
|
MYSERIAL0.begin(BAUDRATE);
|
||||||
SERIAL_ECHOLNPGM("x86_64 Initialized");
|
SERIAL_ECHOLNPGM("x86_64 Initialized");
|
||||||
SERIAL_FLUSHTX();
|
SERIAL_FLUSHTX();
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
||||||
*
|
*
|
||||||
* The only modification was to update/delete macros to match the LPC176x.
|
* The only modification was to update/delete macros to match the LPC176x.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "../../core/macros.h"
|
#include "../../core/macros.h"
|
||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if BOTH(HAS_GRAPHICAL_LCD, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
#if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||||
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
||||||
// needed due to the speed and mode required for communicating with each device being different.
|
// needed due to the speed and mode required for communicating with each device being different.
|
||||||
// This requirement can be removed if the SPI access to these devices is updated to use
|
// This requirement can be removed if the SPI access to these devices is updated to use
|
||||||
|
@ -63,58 +63,35 @@ extern "C" volatile uint32_t _millis;
|
|||||||
#define ST7920_DELAY_3 DELAY_NS(750)
|
#define ST7920_DELAY_3 DELAY_NS(750)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _MSERIAL(X) MSerial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define MSerial0 MSerial
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 UsbSerial
|
#define MYSERIAL0 UsbSerial
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 MSerial
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 MSerial1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 MSerial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 MSerial3
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
#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
|
#define MYSERIAL1 UsbSerial
|
||||||
#elif SERIAL_PORT_2 == 0
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 MSerial
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 1
|
|
||||||
#define MYSERIAL1 MSerial1
|
|
||||||
#elif SERIAL_PORT_2 == 2
|
|
||||||
#define MYSERIAL1 MSerial2
|
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 MSerial3
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
#if LCD_SERIAL_PORT == -1
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
#define LCD_SERIAL UsbSerial
|
||||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#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
|
#else
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
|
* WRITE nor digitalWrite when the hardware SPI module within the LPC17xx is
|
||||||
* active. If any of these pins are shared then the software SPI must be used.
|
* active. If any of these pins are shared then the software SPI must be used.
|
||||||
*
|
*
|
||||||
* A more sophisticated hardware SPI can be found at the following link. This
|
* A more sophisticated hardware SPI can be found at the following link.
|
||||||
* implementation has not been fully debugged.
|
* This implementation has not been fully debugged.
|
||||||
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
|
* https://github.com/MarlinFirmware/Marlin/tree/071c7a78f27078fd4aee9a3ef365fcf5e143531e
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -100,72 +100,25 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// decide which HW SPI device to use
|
|
||||||
#ifndef LPC_HW_SPI_DEV
|
|
||||||
#if (SCK_PIN == P0_07 && MISO_PIN == P0_08 && MOSI_PIN == P0_09)
|
|
||||||
#define LPC_HW_SPI_DEV 1
|
|
||||||
#else
|
|
||||||
#if (SCK_PIN == P0_15 && MISO_PIN == P0_17 && MOSI_PIN == P0_18)
|
|
||||||
#define LPC_HW_SPI_DEV 0
|
|
||||||
#else
|
|
||||||
#error "Invalid pins selected for hardware SPI"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if LPC_HW_SPI_DEV == 0
|
|
||||||
#define LPC_SSPn LPC_SSP0
|
|
||||||
#else
|
|
||||||
#define LPC_SSPn LPC_SSP1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
|
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
|
||||||
PINSEL_CFG_Type PinCfg; // data structure to hold init values
|
spiInit(SPI_SPEED);
|
||||||
PinCfg.Funcnum = 2;
|
|
||||||
PinCfg.OpenDrain = 0;
|
|
||||||
PinCfg.Pinmode = 0;
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(SCK_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(SCK_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(SCK_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(MISO_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(MISO_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_INPUT(MISO_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(MOSI_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(MOSI_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(MOSI_PIN);
|
|
||||||
// divide PCLK by 2 for SSP0
|
|
||||||
CLKPWR_SetPCLKDiv(LPC_HW_SPI_DEV == 0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
|
|
||||||
spiInit(0);
|
|
||||||
SSP_Cmd(LPC_SSPn, ENABLE); // start SSP running
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiInit(uint8_t spiRate) {
|
void spiInit(uint8_t spiRate) {
|
||||||
// table to convert Marlin spiRates (0-5 plus default) into bit rates
|
#if MISO_PIN == BOARD_SPI1_MISO_PIN
|
||||||
uint32_t Marlin_speed[7]; // CPSR is always 2
|
SPI.setModule(1);
|
||||||
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
|
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
|
||||||
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
|
SPI.setModule(2);
|
||||||
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
|
#endif
|
||||||
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
|
SPI.setDataSize(DATA_SIZE_8BIT);
|
||||||
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
|
SPI.setDataMode(SPI_MODE0);
|
||||||
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
|
|
||||||
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
|
SPI.setClock(SPISettings::spiRate2Clock(spiRate));
|
||||||
// setup for SPI mode
|
SPI.begin();
|
||||||
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
|
|
||||||
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
|
|
||||||
HW_SPI_init.ClockRate = Marlin_speed[_MIN(spiRate, 6)]; // put in the specified bit rate
|
|
||||||
HW_SPI_init.Mode |= SSP_CR1_SSP_EN;
|
|
||||||
SSP_Init(LPC_SSPn, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t doio(uint8_t b) {
|
static uint8_t doio(uint8_t b) {
|
||||||
/* send and receive a single byte */
|
return SPI.transfer(b & 0x00FF) & 0x00FF;
|
||||||
SSP_SendData(LPC_SSPn, b & 0x00FF);
|
|
||||||
while (SSP_GetStatus(LPC_SSPn, SSP_STAT_BUSY)); // wait for it to finish
|
|
||||||
return SSP_ReceiveData(LPC_SSPn) & 0x00FF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiSend(uint8_t b) { doio(b); }
|
void spiSend(uint8_t b) { doio(b); }
|
||||||
@ -217,63 +170,74 @@ static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
|
|||||||
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
|
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retain the pin init state of the SPI, to avoid init more than once,
|
||||||
|
// even if more instances of SPIClass exist
|
||||||
|
static bool spiInitialised[BOARD_NR_SPI] = { false };
|
||||||
|
|
||||||
SPIClass::SPIClass(uint8_t device) {
|
SPIClass::SPIClass(uint8_t device) {
|
||||||
// Init things specific to each SPI device
|
// Init things specific to each SPI device
|
||||||
// clock divider setup is a bit of hack, and needs to be improved at a later date.
|
// clock divider setup is a bit of hack, and needs to be improved at a later date.
|
||||||
|
|
||||||
PINSEL_CFG_Type PinCfg; // data structure to hold init values
|
|
||||||
#if BOARD_NR_SPI >= 1
|
#if BOARD_NR_SPI >= 1
|
||||||
_settings[0].spi_d = LPC_SSP0;
|
_settings[0].spi_d = LPC_SSP0;
|
||||||
// _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
|
_settings[0].dataMode = SPI_MODE0;
|
||||||
PinCfg.Funcnum = 2;
|
_settings[0].dataSize = DATA_SIZE_8BIT;
|
||||||
PinCfg.OpenDrain = 0;
|
_settings[0].clock = SPI_CLOCK_MAX;
|
||||||
PinCfg.Pinmode = 0;
|
//_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_SCK_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_SCK_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(BOARD_SPI1_SCK_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MISO_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MISO_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_INPUT(BOARD_SPI1_MISO_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MOSI_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MOSI_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(BOARD_SPI1_MOSI_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_NR_SPI >= 2
|
#if BOARD_NR_SPI >= 2
|
||||||
_settings[1].spi_d = LPC_SSP1;
|
_settings[1].spi_d = LPC_SSP1;
|
||||||
// _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
|
_settings[1].dataMode = SPI_MODE0;
|
||||||
PinCfg.Funcnum = 2;
|
_settings[1].dataSize = DATA_SIZE_8BIT;
|
||||||
PinCfg.OpenDrain = 0;
|
_settings[1].clock = SPI_CLOCK_MAX;
|
||||||
PinCfg.Pinmode = 0;
|
//_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_SCK_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_SCK_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(BOARD_SPI2_SCK_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MISO_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MISO_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_INPUT(BOARD_SPI2_MISO_PIN);
|
|
||||||
|
|
||||||
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MOSI_PIN);
|
|
||||||
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MOSI_PIN);
|
|
||||||
PINSEL_ConfigPin(&PinCfg);
|
|
||||||
SET_OUTPUT(BOARD_SPI2_MOSI_PIN);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setModule(device);
|
setModule(device);
|
||||||
|
|
||||||
/* Initialize GPDMA controller */
|
// Init the GPDMA controller
|
||||||
//TODO: call once in the constructor? or each time?
|
// TODO: call once in the constructor? or each time?
|
||||||
GPDMA_Init();
|
GPDMA_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::begin() {
|
void SPIClass::begin() {
|
||||||
|
// Init the SPI pins in the first begin call
|
||||||
|
if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
|
||||||
|
(_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) {
|
||||||
|
pin_t sck, miso, mosi;
|
||||||
|
if (_currentSetting->spi_d == LPC_SSP0) {
|
||||||
|
sck = BOARD_SPI1_SCK_PIN;
|
||||||
|
miso = BOARD_SPI1_MISO_PIN;
|
||||||
|
mosi = BOARD_SPI1_MOSI_PIN;
|
||||||
|
spiInitialised[0] = true;
|
||||||
|
}
|
||||||
|
else if (_currentSetting->spi_d == LPC_SSP1) {
|
||||||
|
sck = BOARD_SPI2_SCK_PIN;
|
||||||
|
miso = BOARD_SPI2_MISO_PIN;
|
||||||
|
mosi = BOARD_SPI2_MOSI_PIN;
|
||||||
|
spiInitialised[1] = true;
|
||||||
|
}
|
||||||
|
PINSEL_CFG_Type PinCfg; // data structure to hold init values
|
||||||
|
PinCfg.Funcnum = 2;
|
||||||
|
PinCfg.OpenDrain = 0;
|
||||||
|
PinCfg.Pinmode = 0;
|
||||||
|
PinCfg.Pinnum = LPC176x::pin_bit(sck);
|
||||||
|
PinCfg.Portnum = LPC176x::pin_port(sck);
|
||||||
|
PINSEL_ConfigPin(&PinCfg);
|
||||||
|
SET_OUTPUT(sck);
|
||||||
|
|
||||||
|
PinCfg.Pinnum = LPC176x::pin_bit(miso);
|
||||||
|
PinCfg.Portnum = LPC176x::pin_port(miso);
|
||||||
|
PINSEL_ConfigPin(&PinCfg);
|
||||||
|
SET_INPUT(miso);
|
||||||
|
|
||||||
|
PinCfg.Pinnum = LPC176x::pin_bit(mosi);
|
||||||
|
PinCfg.Portnum = LPC176x::pin_port(mosi);
|
||||||
|
PINSEL_ConfigPin(&PinCfg);
|
||||||
|
SET_OUTPUT(mosi);
|
||||||
|
}
|
||||||
|
|
||||||
updateSettings();
|
updateSettings();
|
||||||
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
|
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
|
||||||
}
|
}
|
||||||
@ -287,7 +251,7 @@ void SPIClass::beginTransaction(const SPISettings &cfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SPIClass::transfer(const uint16_t b) {
|
uint8_t SPIClass::transfer(const uint16_t b) {
|
||||||
/* send and receive a single byte */
|
// Send and receive a single byte
|
||||||
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
|
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
|
||||||
SSP_SendData(_currentSetting->spi_d, b);
|
SSP_SendData(_currentSetting->spi_d, b);
|
||||||
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
|
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
|
||||||
@ -295,8 +259,7 @@ uint8_t SPIClass::transfer(const uint16_t b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t SPIClass::transfer16(const uint16_t data) {
|
uint16_t SPIClass::transfer16(const uint16_t data) {
|
||||||
return (transfer((data >> 8) & 0xFF) << 8)
|
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
|
||||||
| (transfer(data & 0xFF) & 0xFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::end() {
|
void SPIClass::end() {
|
||||||
@ -320,7 +283,7 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
|
|||||||
// Destination memory - Not used
|
// Destination memory - Not used
|
||||||
GPDMACfg.DstMemAddr = 0;
|
GPDMACfg.DstMemAddr = 0;
|
||||||
// Transfer size
|
// Transfer size
|
||||||
GPDMACfg.TransferSize = (minc ? length : 1);
|
GPDMACfg.TransferSize = length;
|
||||||
// Transfer width
|
// Transfer width
|
||||||
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
|
GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE;
|
||||||
// Transfer type
|
// Transfer type
|
||||||
@ -335,27 +298,25 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
|
|||||||
// Enable dma on SPI
|
// Enable dma on SPI
|
||||||
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
|
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE);
|
||||||
|
|
||||||
// if minc=false, I'm repeating the same byte 'length' times, as I could not find yet how do GPDMA without memory increment
|
// Only increase memory if minc is true
|
||||||
do {
|
GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0);
|
||||||
|
|
||||||
// Setup channel with given parameter
|
// Setup channel with given parameter
|
||||||
GPDMA_Setup(&GPDMACfg);
|
GPDMA_Setup(&GPDMACfg);
|
||||||
|
|
||||||
// enabled dma
|
// Enable DMA
|
||||||
GPDMA_ChannelCmd(0, ENABLE);
|
GPDMA_ChannelCmd(0, ENABLE);
|
||||||
|
|
||||||
// wait data transfer
|
// Wait for data transfer
|
||||||
while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) { }
|
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
|
||||||
|
|
||||||
// clear err and int
|
// Clear err and int
|
||||||
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
|
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
|
||||||
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
|
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
|
||||||
|
|
||||||
// dma disable
|
// Disable DMA
|
||||||
GPDMA_ChannelCmd(0, DISABLE);
|
GPDMA_ChannelCmd(0, DISABLE);
|
||||||
|
|
||||||
--length;
|
|
||||||
} while (!minc && length > 0);
|
|
||||||
|
|
||||||
waitSpiTxEnd(_currentSetting->spi_d);
|
waitSpiTxEnd(_currentSetting->spi_d);
|
||||||
|
|
||||||
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
|
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
|
||||||
@ -382,7 +343,7 @@ void SPIClass::setBitOrder(uint8_t bitOrder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::setDataMode(uint8_t dataMode) {
|
void SPIClass::setDataMode(uint8_t dataMode) {
|
||||||
_currentSetting->dataSize = dataMode;
|
_currentSetting->dataMode = dataMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::setDataSize(uint32_t ds) {
|
void SPIClass::setDataSize(uint32_t ds) {
|
||||||
|
@ -24,28 +24,28 @@
|
|||||||
#include "../../inc/MarlinConfigPre.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
#include "MarlinSerial.h"
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
|
#if USING_SERIAL_0
|
||||||
MarlinSerial MSerial(LPC_UART0);
|
MarlinSerial MSerial(LPC_UART0);
|
||||||
extern "C" void UART0_IRQHandler() {
|
extern "C" void UART0_IRQHandler() {
|
||||||
MSerial.IRQHandler();
|
MSerial.IRQHandler();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
|
#if USING_SERIAL_1
|
||||||
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
||||||
extern "C" void UART1_IRQHandler() {
|
extern "C" void UART1_IRQHandler() {
|
||||||
MSerial1.IRQHandler();
|
MSerial1.IRQHandler();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
|
#if USING_SERIAL_2
|
||||||
MarlinSerial MSerial2(LPC_UART2);
|
MarlinSerial MSerial2(LPC_UART2);
|
||||||
extern "C" void UART2_IRQHandler() {
|
extern "C" void UART2_IRQHandler() {
|
||||||
MSerial2.IRQHandler();
|
MSerial2.IRQHandler();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
|
#if USING_SERIAL_3
|
||||||
MarlinSerial MSerial3(LPC_UART3);
|
MarlinSerial MSerial3(LPC_UART3);
|
||||||
extern "C" void UART3_IRQHandler() {
|
extern "C" void UART3_IRQHandler() {
|
||||||
MSerial3.IRQHandler();
|
MSerial3.IRQHandler();
|
||||||
|
@ -57,6 +57,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
EmergencyParser::State emergency_state;
|
EmergencyParser::State emergency_state;
|
||||||
|
static inline bool emergency_parser_enabled() { return true; }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
* Version 2 Copyright (c) 2009 Michael Margolis. All right reserved.
|
||||||
*
|
*
|
||||||
* The only modification was to update/delete macros to match the LPC176x.
|
* The only modification was to update/delete macros to match the LPC176x.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#if PIO_PLATFORM_VERSION < 1001
|
#if PIO_PLATFORM_VERSION < 1001
|
||||||
#error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
|
#error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
|
||||||
#endif
|
#endif
|
||||||
#if PIO_FRAMEWORK_VERSION < 2002
|
#if PIO_FRAMEWORK_VERSION < 2005
|
||||||
#error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
|
#error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -89,7 +89,10 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
* Serial2 | P0_10 | P0_11 |
|
* Serial2 | P0_10 | P0_11 |
|
||||||
* Serial3 | P0_00 | P0_01 |
|
* Serial3 | P0_00 | P0_01 |
|
||||||
*/
|
*/
|
||||||
#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
|
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
|
||||||
|
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
|
||||||
|
|
||||||
|
#if USING_SERIAL_0
|
||||||
#define IS_TX0(P) (P == P0_02)
|
#define IS_TX0(P) (P == P0_02)
|
||||||
#define IS_RX0(P) (P == P0_03)
|
#define IS_RX0(P) (P == P0_03)
|
||||||
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
|
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
|
||||||
@ -103,60 +106,67 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#undef IS_RX0
|
#undef IS_RX0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
|
#if USING_SERIAL_1
|
||||||
#define IS_TX1(P) (P == P0_15)
|
#define IS_TX1(P) (P == P0_15)
|
||||||
#define IS_RX1(P) (P == P0_16)
|
#define IS_RX1(P) (P == P0_16)
|
||||||
|
#define _IS_TX1_1 IS_TX1
|
||||||
|
#define _IS_RX1_1 IS_RX1
|
||||||
#if IS_TX1(TMC_SW_SCK)
|
#if IS_TX1(TMC_SW_SCK)
|
||||||
#error "Serial port pins (1) conflict with other pins!"
|
#error "Serial port pins (1) conflict with other pins!"
|
||||||
#elif HAS_SPI_LCD
|
#elif HAS_WIRED_LCD
|
||||||
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
|
||||||
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
#error "Serial port pins (1) conflict with Encoder Buttons!"
|
||||||
#elif IS_TX1(SCK_PIN) || IS_TX1(LCD_PINS_D4) || IS_TX1(DOGLCD_SCK) || IS_TX1(LCD_RESET_PIN) || IS_TX1(LCD_PINS_RS) || IS_TX1(SHIFT_CLK) \
|
#elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
|
||||||
|| IS_RX1(LCD_SDSS) || IS_RX1(LCD_PINS_RS) || IS_RX1(MISO_PIN) || IS_RX1(DOGLCD_A0) || IS_RX1(SS_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(DOGLCD_CS) || IS_RX1(LCD_RESET_PIN) || IS_RX1(LCD_BACKLIGHT_PIN)
|
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
|
||||||
#error "Serial port pins (1) conflict with LCD pins!"
|
#error "Serial port pins (1) conflict with LCD pins!"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#undef IS_TX1
|
#undef IS_TX1
|
||||||
#undef IS_RX1
|
#undef IS_RX1
|
||||||
|
#undef _IS_TX1_1
|
||||||
|
#undef _IS_RX1_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
|
#if USING_SERIAL_2
|
||||||
#define IS_TX2(P) (P == P0_10)
|
#define IS_TX2(P) (P == P0_10)
|
||||||
#define IS_RX2(P) (P == P0_11)
|
#define IS_RX2(P) (P == P0_11)
|
||||||
#if IS_TX2(X2_ENABLE_PIN) || IS_RX2(X2_DIR_PIN) || IS_RX2(X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
|
#define _IS_TX2_1 IS_TX2
|
||||||
|
#define _IS_RX2_1 IS_RX2
|
||||||
|
#if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
|
||||||
#error "Serial port pins (2) conflict with X2 pins!"
|
#error "Serial port pins (2) conflict with X2 pins!"
|
||||||
#elif IS_TX2(Y2_ENABLE_PIN) || IS_RX2(Y2_DIR_PIN) || IS_RX2(Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
|
#elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
|
||||||
#error "Serial port pins (2) conflict with Y2 pins!"
|
#error "Serial port pins (2) conflict with Y2 pins!"
|
||||||
#elif IS_TX2(Z2_ENABLE_PIN) || IS_RX2(Z2_DIR_PIN) || IS_RX2(Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
|
#elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
|
||||||
#error "Serial port pins (2) conflict with Z2 pins!"
|
#error "Serial port pins (2) conflict with Z2 pins!"
|
||||||
#elif IS_TX2(Z3_ENABLE_PIN) || IS_RX2(Z3_DIR_PIN) || IS_RX2(Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
|
#elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
|
||||||
#error "Serial port pins (2) conflict with Z3 pins!"
|
#error "Serial port pins (2) conflict with Z3 pins!"
|
||||||
#elif IS_TX2(Z4_ENABLE_PIN) || IS_RX2(Z4_DIR_PIN) || IS_RX2(Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
|
#elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
|
||||||
#error "Serial port pins (2) conflict with Z4 pins!"
|
#error "Serial port pins (2) conflict with Z4 pins!"
|
||||||
#elif IS_RX2(X_DIR_PIN) || IS_RX2(Y_DIR_PIN)
|
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
|
||||||
#error "Serial port pins (2) conflict with other pins!"
|
#error "Serial port pins (2) conflict with other pins!"
|
||||||
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
|
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
|
||||||
#error "Serial port pins (2) conflict with Y endstop pin!"
|
#error "Serial port pins (2) conflict with Y endstop pin!"
|
||||||
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
|
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
|
||||||
#error "Serial port pins (2) conflict with probe pin!"
|
#error "Serial port pins (2) conflict with probe pin!"
|
||||||
#elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN)
|
#elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
|
||||||
#error "Serial port pins (2) conflict with X/Y stepper pins!"
|
#error "Serial port pins (2) conflict with X/Y stepper pins!"
|
||||||
#elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
|
#elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
|
||||||
#error "Serial port pins (2) conflict with E1 stepper pins!"
|
#error "Serial port pins (2) conflict with E1 stepper pins!"
|
||||||
#elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN))
|
#elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN)
|
||||||
#error "Serial port pins (2) conflict with E stepper pins!"
|
#error "Serial port pins (2) conflict with E stepper pins!"
|
||||||
#endif
|
#endif
|
||||||
#undef IS_TX2
|
#undef IS_TX2
|
||||||
#undef IS_RX2
|
#undef IS_RX2
|
||||||
|
#undef _IS_TX2_1
|
||||||
|
#undef _IS_RX2_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
|
#if USING_SERIAL_3
|
||||||
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
|
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
|
||||||
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
|
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
|
||||||
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
|
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
|
||||||
#error "Serial port pins (3) conflict with X endstop pins!"
|
#error "Serial port pins (3) conflict with X endstop pins!"
|
||||||
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) \
|
#elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
|
||||||
|| PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
|
|
||||||
#error "Serial port pins (3) conflict with X/Y axis UART pins!"
|
#error "Serial port pins (3) conflict with X/Y axis UART pins!"
|
||||||
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
|
#elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
|
||||||
#error "Serial port pins (3) conflict with X2 pins!"
|
#error "Serial port pins (3) conflict with X2 pins!"
|
||||||
@ -168,13 +178,16 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#error "Serial port pins (3) conflict with Z3 pins!"
|
#error "Serial port pins (3) conflict with Z3 pins!"
|
||||||
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
|
#elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
|
||||||
#error "Serial port pins (3) conflict with Z4 pins!"
|
#error "Serial port pins (3) conflict with Z4 pins!"
|
||||||
#elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
|
#elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
|
||||||
#error "Serial port pins (3) conflict with E1 pins!"
|
#error "Serial port pins (3) conflict with E1 pins!"
|
||||||
#endif
|
#endif
|
||||||
#undef PIN_IS_TX3
|
#undef PIN_IS_TX3
|
||||||
#undef PIN_IS_RX3
|
#undef PIN_IS_RX3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef ANY_TX
|
||||||
|
#undef ANY_RX
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flag any i2c pin conflicts
|
// Flag any i2c pin conflicts
|
||||||
//
|
//
|
||||||
@ -214,7 +227,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
|
#error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
|
||||||
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
|
#elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
|
||||||
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
|
#error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
|
||||||
#elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
|
#elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
|
||||||
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
|
#error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
|
||||||
#endif
|
#endif
|
||||||
#undef PIN_IS_SDA1
|
#undef PIN_IS_SDA1
|
||||||
@ -240,9 +253,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
|||||||
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
|
#error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
|
||||||
#elif PIN_IS_SDA2(Z4_ENABLE)
|
#elif PIN_IS_SDA2(Z4_ENABLE)
|
||||||
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
|
#error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
|
||||||
#elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE)
|
#elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE)
|
||||||
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
|
#error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
|
||||||
#elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
|
#elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
|
||||||
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
|
#error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
|
||||||
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
|
#elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
|
||||||
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
|
#error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
|
||||||
|
@ -61,7 +61,9 @@
|
|||||||
|
|
||||||
class SPISettings {
|
class SPISettings {
|
||||||
public:
|
public:
|
||||||
SPISettings(uint32_t speed, int, int) : spi_speed(speed) {};
|
SPISettings(uint32_t spiRate, int inBitOrder, int inDataMode) {
|
||||||
|
init_AlwaysInline(spiRate2Clock(spiRate), inBitOrder, inDataMode, DATA_SIZE_8BIT);
|
||||||
|
}
|
||||||
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
SPISettings(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
||||||
if (__builtin_constant_p(inClock))
|
if (__builtin_constant_p(inClock))
|
||||||
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
|
init_AlwaysInline(inClock, inBitOrder, inDataMode, inDataSize);
|
||||||
@ -72,7 +74,19 @@ public:
|
|||||||
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
|
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t spiRate() const { return spi_speed; }
|
//uint32_t spiRate() const { return spi_speed; }
|
||||||
|
|
||||||
|
static inline uint32_t spiRate2Clock(uint32_t spiRate) {
|
||||||
|
uint32_t Marlin_speed[7]; // CPSR is always 2
|
||||||
|
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
|
||||||
|
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
|
||||||
|
Marlin_speed[2] = 2083333; //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
|
||||||
|
Marlin_speed[3] = 1000000; //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
|
||||||
|
Marlin_speed[4] = 500000; //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
|
||||||
|
Marlin_speed[5] = 250000; //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
|
||||||
|
Marlin_speed[6] = 125000; //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
|
||||||
|
return Marlin_speed[spiRate > 6 ? 6 : spiRate];
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
void init_MightInline(uint32_t inClock, uint8_t inBitOrder, uint8_t inDataMode, uint32_t inDataSize) {
|
||||||
@ -85,7 +99,7 @@ private:
|
|||||||
dataSize = inDataSize;
|
dataSize = inDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t spi_speed;
|
//uint32_t spi_speed;
|
||||||
uint32_t clock;
|
uint32_t clock;
|
||||||
uint32_t dataSize;
|
uint32_t dataSize;
|
||||||
//uint32_t clockDivider;
|
//uint32_t clockDivider;
|
||||||
@ -122,7 +136,7 @@ public:
|
|||||||
void end();
|
void end();
|
||||||
|
|
||||||
void beginTransaction(const SPISettings&);
|
void beginTransaction(const SPISettings&);
|
||||||
void endTransaction() {};
|
void endTransaction() {}
|
||||||
|
|
||||||
// Transfer using 1 "Data Size"
|
// Transfer using 1 "Data Size"
|
||||||
uint8_t transfer(uint16_t data);
|
uint8_t transfer(uint16_t data);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "../../core/macros.h"
|
#include "../../core/macros.h"
|
||||||
|
|
||||||
#if BOTH(SDSUPPORT, HAS_GRAPHICAL_LCD) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
#if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SCK_PIN || LCD_PINS_ENABLE == MOSI_PIN || DOGLCD_SCK == SCK_PIN || DOGLCD_MOSI == MOSI_PIN)
|
||||||
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
#define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
|
||||||
// needed due to the speed and mode required for communicating with each device being different.
|
// needed due to the speed and mode required for communicating with each device being different.
|
||||||
// This requirement can be removed if the SPI access to these devices is updated to use
|
// This requirement can be removed if the SPI access to these devices is updated to use
|
||||||
|
@ -72,7 +72,6 @@ bool XPT2046::getRawPoint(int16_t *x, int16_t *y) {
|
|||||||
if (!isTouched()) return false;
|
if (!isTouched()) return false;
|
||||||
*x = getRawData(XPT2046_X);
|
*x = getRawData(XPT2046_X);
|
||||||
*y = getRawData(XPT2046_Y);
|
*y = getRawData(XPT2046_Y);
|
||||||
SERIAL_ECHOLNPAIR("X: ", *x, ", Y: ", *y);
|
|
||||||
return isTouched();
|
return isTouched();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* HAL For LPC1768
|
* HAL For LPC1768
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
#include "../../shared/HAL_SPI.h"
|
#include "../../shared/HAL_SPI.h"
|
||||||
@ -124,6 +124,6 @@ uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
|
|
||||||
@ -193,6 +193,6 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD
|
#if HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
#include "../../shared/HAL_SPI.h"
|
#include "../../shared/HAL_SPI.h"
|
||||||
@ -133,6 +133,6 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920)
|
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||||
|
|
||||||
#include <SoftwareSPI.h>
|
#include <SoftwareSPI.h>
|
||||||
|
|
||||||
@ -203,5 +203,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD && !U8GLIB_ST7920
|
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
|
||||||
#endif // TARGET_LPC1768
|
#endif // TARGET_LPC1768
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
#if ENABLED(EMERGENCY_PARSER)
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
|
||||||
#include "../../feature/e_parser.h"
|
#include "../../feature/e_parser.h"
|
||||||
|
|
||||||
EmergencyParser::State emergency_state;
|
EmergencyParser::State emergency_state;
|
||||||
|
|
||||||
bool CDC_RecvCallback(const char buffer) {
|
bool CDC_RecvCallback(const char buffer) {
|
||||||
emergency_parser.update(emergency_state, buffer);
|
emergency_parser.update(emergency_state, buffer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,58 +35,34 @@
|
|||||||
|
|
||||||
// MYSERIAL0 required before MarlinSerial includes!
|
// MYSERIAL0 required before MarlinSerial includes!
|
||||||
|
|
||||||
|
#define _MSERIAL(X) Serial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 Serial
|
#define MYSERIAL0 Serial
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 Serial1
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 Serial2
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 Serial3
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 Serial4
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == SERIAL_PORT
|
#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 Serial
|
#define MYSERIAL1 Serial
|
||||||
#elif SERIAL_PORT_2 == 0
|
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||||
#define MYSERIAL1 Serial1
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 1
|
|
||||||
#define MYSERIAL1 Serial2
|
|
||||||
#elif SERIAL_PORT_2 == 2
|
|
||||||
#define MYSERIAL1 Serial3
|
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 Serial4
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if DGUS_SERIAL_PORT == SERIAL_PORT
|
#if LCD_SERIAL_PORT == -1
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
#define LCD_SERIAL Serial
|
||||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#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
|
#else
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* Derived from Adafruit_SPIFlash class with no SdFat references
|
* Derived from Adafruit_SPIFlash class with no SdFat references
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -150,5 +150,4 @@ void pwm_details(int32_t pin) {
|
|||||||
* 93 | PA10 | QSPI: IO2
|
* 93 | PA10 | QSPI: IO2
|
||||||
* 94 | PA11 | QSPI: IO3
|
* 94 | PA11 | QSPI: IO3
|
||||||
* 95 | PB31 | SD: DETECT
|
* 95 | PB31 | SD: DETECT
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@ -43,83 +43,40 @@
|
|||||||
// ------------------------
|
// ------------------------
|
||||||
// Defines
|
// Defines
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
#define _MSERIAL(X) MSerial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
|
||||||
#if SERIAL_PORT == 0
|
#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
|
#define MYSERIAL0 SerialUSB
|
||||||
#elif SERIAL_PORT == 1
|
#elif WITHIN(SERIAL_PORT, 1, 6)
|
||||||
#define MYSERIAL0 MSerial1
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 MSerial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 MSerial3
|
|
||||||
#elif SERIAL_PORT == 4
|
|
||||||
#define MYSERIAL0 MSerial4
|
|
||||||
#elif SERIAL_PORT == 5
|
|
||||||
#define MYSERIAL0 MSerial5
|
|
||||||
#elif SERIAL_PORT == 6
|
|
||||||
#define MYSERIAL0 MSerial6
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
#error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#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
|
#define MYSERIAL1 SerialUSB
|
||||||
#elif SERIAL_PORT_2 == 1
|
#elif WITHIN(SERIAL_PORT_2, 1, 6)
|
||||||
#define MYSERIAL1 MSerial1
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 2
|
|
||||||
#define MYSERIAL1 MSerial2
|
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 MSerial3
|
|
||||||
#elif SERIAL_PORT_2 == 4
|
|
||||||
#define MYSERIAL1 MSerial4
|
|
||||||
#elif SERIAL_PORT_2 == 5
|
|
||||||
#define MYSERIAL1 MSerial5
|
|
||||||
#elif SERIAL_PORT_2 == 6
|
|
||||||
#define MYSERIAL1 MSerial6
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
|
#error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_DGUS_LCD
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if DGUS_SERIAL_PORT == 0
|
#if LCD_SERIAL_PORT == -1
|
||||||
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
#define LCD_SERIAL SerialUSB
|
||||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#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 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
|
|
||||||
#elif DGUS_SERIAL_PORT == 6
|
|
||||||
#define DGUS_SERIAL MSerial6
|
|
||||||
#else
|
#else
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#if HAS_DGUS_LCD
|
||||||
|
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: review this to return 1 for pins that are not analog input
|
* TODO: review this to return 1 for pins that are not analog input
|
||||||
*/
|
*/
|
||||||
|
@ -49,16 +49,14 @@
|
|||||||
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
|
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT >= 0
|
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
|
||||||
DECLARE_SERIAL_PORT_EXP(DGUS_SERIAL_PORT)
|
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MarlinSerial::begin(unsigned long baud, uint8_t config) {
|
void MarlinSerial::begin(unsigned long baud, uint8_t config) {
|
||||||
HardwareSerial::begin(baud, config);
|
HardwareSerial::begin(baud, config);
|
||||||
// replace the IRQ callback with the one we have defined
|
// Replace the IRQ callback with the one we have defined
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
TERN_(EMERGENCY_PARSER, _serial.rx_callback = _rx_callback);
|
||||||
_serial.rx_callback = _rx_callback;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is Copyright (c) 2006 Nicholas Zambetti.
|
// This function is Copyright (c) 2006 Nicholas Zambetti.
|
||||||
|
@ -35,6 +35,10 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
static inline bool emergency_parser_enabled() { return true; }
|
||||||
|
#endif
|
||||||
|
|
||||||
void begin(unsigned long baud, uint8_t config);
|
void begin(unsigned long baud, uint8_t config);
|
||||||
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
||||||
|
|
||||||
|
@ -1,396 +0,0 @@
|
|||||||
/*
|
|
||||||
* SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
|
|
||||||
*
|
|
||||||
* Multi-instance software serial library for Arduino/Wiring
|
|
||||||
* -- Interrupt-driven receive and other improvements by ladyada
|
|
||||||
* <https://ladyada.net>
|
|
||||||
* -- Tuning, circular buffer, derivation from class Print/Stream,
|
|
||||||
* multi-instance support, porting to 8MHz processors,
|
|
||||||
* various optimizations, PROGMEM delay tables, inverse logic and
|
|
||||||
* direct port writing by Mikal Hart <http://www.arduiniana.org>
|
|
||||||
* -- Pin change interrupt macros by Paul Stoffregen <https://www.pjrc.com>
|
|
||||||
* -- 20MHz processor support by Garrett Mace <http://www.macetech.com>
|
|
||||||
* -- ATmega1280/2560 support by Brett Hagman <https://www.roguerobotics.com>
|
|
||||||
* -- STM32 support by Armin van der Togt
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* The latest version of this library can always be found at
|
|
||||||
* http://arduiniana.org.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// Includes
|
|
||||||
//
|
|
||||||
#if defined(PLATFORMIO) && defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#include "SoftwareSerial.h"
|
|
||||||
|
|
||||||
#define OVERSAMPLE 3 // in RX, Timer will generate interruption OVERSAMPLE time during a bit. Thus OVERSAMPLE ticks in a bit. (interrupt not synchonized with edge).
|
|
||||||
|
|
||||||
// defined in bit-periods
|
|
||||||
#define HALFDUPLEX_SWITCH_DELAY 5
|
|
||||||
// It's best to define TIMER_SERIAL in variant.h. If not defined, we choose one here
|
|
||||||
// The order is based on (lack of) features and compare channels, we choose the simplest available
|
|
||||||
// because we only need an update interrupt
|
|
||||||
#if !defined(TIMER_SERIAL)
|
|
||||||
#if defined(TIM18_BASE)
|
|
||||||
#define TIMER_SERIAL TIM18
|
|
||||||
#elif defined(TIM7_BASE)
|
|
||||||
#define TIMER_SERIAL TIM7
|
|
||||||
#elif defined(TIM6_BASE)
|
|
||||||
#define TIMER_SERIAL TIM6
|
|
||||||
#elif defined(TIM22_BASE)
|
|
||||||
#define TIMER_SERIAL TIM22
|
|
||||||
#elif defined(TIM21_BASE)
|
|
||||||
#define TIMER_SERIAL TIM21
|
|
||||||
#elif defined(TIM17_BASE)
|
|
||||||
#define TIMER_SERIAL TIM17
|
|
||||||
#elif defined(TIM16_BASE)
|
|
||||||
#define TIMER_SERIAL TIM16
|
|
||||||
#elif defined(TIM15_BASE)
|
|
||||||
#define TIMER_SERIAL TIM15
|
|
||||||
#elif defined(TIM14_BASE)
|
|
||||||
#define TIMER_SERIAL TIM14
|
|
||||||
#elif defined(TIM13_BASE)
|
|
||||||
#define TIMER_SERIAL TIM13
|
|
||||||
#elif defined(TIM11_BASE)
|
|
||||||
#define TIMER_SERIAL TIM11
|
|
||||||
#elif defined(TIM10_BASE)
|
|
||||||
#define TIMER_SERIAL TIM10
|
|
||||||
#elif defined(TIM12_BASE)
|
|
||||||
#define TIMER_SERIAL TIM12
|
|
||||||
#elif defined(TIM19_BASE)
|
|
||||||
#define TIMER_SERIAL TIM19
|
|
||||||
#elif defined(TIM9_BASE)
|
|
||||||
#define TIMER_SERIAL TIM9
|
|
||||||
#elif defined(TIM5_BASE)
|
|
||||||
#define TIMER_SERIAL TIM5
|
|
||||||
#elif defined(TIM4_BASE)
|
|
||||||
#define TIMER_SERIAL TIM4
|
|
||||||
#elif defined(TIM3_BASE)
|
|
||||||
#define TIMER_SERIAL TIM3
|
|
||||||
#elif defined(TIM2_BASE)
|
|
||||||
#define TIMER_SERIAL TIM2
|
|
||||||
#elif defined(TIM20_BASE)
|
|
||||||
#define TIMER_SERIAL TIM20
|
|
||||||
#elif defined(TIM8_BASE)
|
|
||||||
#define TIMER_SERIAL TIM8
|
|
||||||
#elif defined(TIM1_BASE)
|
|
||||||
#define TIMER_SERIAL TIM1
|
|
||||||
#else
|
|
||||||
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// Statics
|
|
||||||
//
|
|
||||||
HardwareTimer SoftwareSerial::timer(TIMER_SERIAL);
|
|
||||||
const IRQn_Type SoftwareSerial::timer_interrupt_number = static_cast<IRQn_Type>(getTimerUpIrq(TIMER_SERIAL));
|
|
||||||
uint32_t SoftwareSerial::timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), TIM_IRQ_PRIO, TIM_IRQ_SUBPRIO);
|
|
||||||
SoftwareSerial *SoftwareSerial::active_listener = nullptr;
|
|
||||||
SoftwareSerial *volatile SoftwareSerial::active_out = nullptr;
|
|
||||||
SoftwareSerial *volatile SoftwareSerial::active_in = nullptr;
|
|
||||||
int32_t SoftwareSerial::tx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
|
|
||||||
int32_t volatile SoftwareSerial::rx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
|
|
||||||
uint32_t SoftwareSerial::tx_buffer = 0;
|
|
||||||
int32_t SoftwareSerial::tx_bit_cnt = 0;
|
|
||||||
uint32_t SoftwareSerial::rx_buffer = 0;
|
|
||||||
int32_t SoftwareSerial::rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
|
||||||
uint32_t SoftwareSerial::cur_speed = 0;
|
|
||||||
|
|
||||||
void SoftwareSerial::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority) {
|
|
||||||
timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Private methods
|
|
||||||
//
|
|
||||||
|
|
||||||
void SoftwareSerial::setSpeed(uint32_t speed) {
|
|
||||||
if (speed != cur_speed) {
|
|
||||||
timer.pause();
|
|
||||||
if (speed != 0) {
|
|
||||||
// Disable the timer
|
|
||||||
uint32_t clock_rate, cmp_value;
|
|
||||||
// Get timer clock
|
|
||||||
clock_rate = timer.getTimerClkFreq();
|
|
||||||
int pre = 1;
|
|
||||||
// Calculate prescale an compare value
|
|
||||||
do {
|
|
||||||
cmp_value = clock_rate / (speed * OVERSAMPLE);
|
|
||||||
if (cmp_value >= UINT16_MAX) {
|
|
||||||
clock_rate /= 2;
|
|
||||||
pre *= 2;
|
|
||||||
}
|
|
||||||
} while (cmp_value >= UINT16_MAX);
|
|
||||||
timer.setPrescaleFactor(pre);
|
|
||||||
timer.setOverflow(cmp_value);
|
|
||||||
timer.setCount(0);
|
|
||||||
timer.attachInterrupt(&handleInterrupt);
|
|
||||||
timer.resume();
|
|
||||||
NVIC_SetPriority(timer_interrupt_number, timer_interrupt_priority);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
timer.detachInterrupt();
|
|
||||||
cur_speed = speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function sets the current object as the "listening"
|
|
||||||
// one and returns true if it replaces another
|
|
||||||
bool SoftwareSerial::listen() {
|
|
||||||
if (active_listener != this) {
|
|
||||||
// wait for any transmit to complete as we may change speed
|
|
||||||
while (active_out);
|
|
||||||
active_listener->stopListening();
|
|
||||||
rx_tick_cnt = 1; // 1 : next interrupt will decrease rx_tick_cnt to 0 which means RX pin level will be considered.
|
|
||||||
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
|
||||||
setSpeed(_speed);
|
|
||||||
active_listener = this;
|
|
||||||
if (!_half_duplex) active_in = this;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop listening. Returns true if we were actually listening.
|
|
||||||
bool SoftwareSerial::stopListening() {
|
|
||||||
if (active_listener == this) {
|
|
||||||
// wait for any output to complete
|
|
||||||
while (active_out);
|
|
||||||
if (_half_duplex) setRXTX(false);
|
|
||||||
active_listener = nullptr;
|
|
||||||
active_in = nullptr;
|
|
||||||
// turn off ints
|
|
||||||
setSpeed(0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SoftwareSerial::setTX() {
|
|
||||||
if (_inverse_logic)
|
|
||||||
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
|
|
||||||
else
|
|
||||||
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
|
|
||||||
pinMode(_transmitPin, OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SoftwareSerial::setRX() {
|
|
||||||
pinMode(_receivePin, _inverse_logic ? INPUT_PULLDOWN : INPUT_PULLUP); // pullup for normal logic!
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SoftwareSerial::setRXTX(bool input) {
|
|
||||||
if (_half_duplex) {
|
|
||||||
if (input) {
|
|
||||||
if (active_in != this) {
|
|
||||||
setRX();
|
|
||||||
rx_bit_cnt = -1; // rx_bit_cnt = -1 : waiting for start bit
|
|
||||||
rx_tick_cnt = 2; // 2 : next interrupt will be discarded. 2 interrupts required to consider RX pin level
|
|
||||||
active_in = this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (active_in == this) {
|
|
||||||
setTX();
|
|
||||||
active_in = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SoftwareSerial::send() {
|
|
||||||
if (--tx_tick_cnt <= 0) { // if tx_tick_cnt > 0 interrupt is discarded. Only when tx_tick_cnt reaches 0 is TX pin set.
|
|
||||||
if (tx_bit_cnt++ < 10) { // tx_bit_cnt < 10 transmission is not finished (10 = 1 start +8 bits + 1 stop)
|
|
||||||
// Send data (including start and stop bits)
|
|
||||||
if (tx_buffer & 1)
|
|
||||||
LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
|
|
||||||
else
|
|
||||||
LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
|
|
||||||
tx_buffer >>= 1;
|
|
||||||
tx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks to send next bit
|
|
||||||
}
|
|
||||||
else { // Transmission finished
|
|
||||||
tx_tick_cnt = 1;
|
|
||||||
if (_output_pending) {
|
|
||||||
active_out = nullptr;
|
|
||||||
|
|
||||||
// In half-duplex mode wait HALFDUPLEX_SWITCH_DELAY bit-periods after the byte has
|
|
||||||
// been transmitted before allowing the switch to RX mode
|
|
||||||
}
|
|
||||||
else if (tx_bit_cnt > 10 + OVERSAMPLE * HALFDUPLEX_SWITCH_DELAY) {
|
|
||||||
if (_half_duplex && active_listener == this) setRXTX(true);
|
|
||||||
active_out = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// The receive routine called by the interrupt handler
|
|
||||||
//
|
|
||||||
inline void SoftwareSerial::recv() {
|
|
||||||
if (--rx_tick_cnt <= 0) { // if rx_tick_cnt > 0 interrupt is discarded. Only when rx_tick_cnt reaches 0 is RX pin considered
|
|
||||||
bool inbit = LL_GPIO_IsInputPinSet(_receivePinPort, _receivePinNumber) ^ _inverse_logic;
|
|
||||||
if (rx_bit_cnt == -1) { // rx_bit_cnt = -1 : waiting for start bit
|
|
||||||
if (!inbit) {
|
|
||||||
// got start bit
|
|
||||||
rx_bit_cnt = 0; // rx_bit_cnt == 0 : start bit received
|
|
||||||
rx_tick_cnt = OVERSAMPLE + 1; // Wait 1 bit (OVERSAMPLE ticks) + 1 tick in order to sample RX pin in the middle of the edge (and not too close to the edge)
|
|
||||||
rx_buffer = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rx_tick_cnt = 1; // Waiting for start bit, but wrong level. Wait for next Interrupt to check RX pin level
|
|
||||||
}
|
|
||||||
else if (rx_bit_cnt >= 8) { // rx_bit_cnt >= 8 : waiting for stop bit
|
|
||||||
if (inbit) {
|
|
||||||
// Stop-bit read complete. Add to buffer.
|
|
||||||
uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
|
|
||||||
if (next != _receive_buffer_head) {
|
|
||||||
// save new data in buffer: tail points to byte destination
|
|
||||||
_receive_buffer[_receive_buffer_tail] = rx_buffer; // save new byte
|
|
||||||
_receive_buffer_tail = next;
|
|
||||||
}
|
|
||||||
else // rx_bit_cnt = x with x = [0..7] correspond to new bit x received
|
|
||||||
_buffer_overflow = true;
|
|
||||||
}
|
|
||||||
// Full trame received. Restart waiting for start bit at next interrupt
|
|
||||||
rx_tick_cnt = 1;
|
|
||||||
rx_bit_cnt = -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// data bits
|
|
||||||
rx_buffer >>= 1;
|
|
||||||
if (inbit) rx_buffer |= 0x80;
|
|
||||||
rx_bit_cnt++; // Prepare for next bit
|
|
||||||
rx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks before sampling next bit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Interrupt handling
|
|
||||||
//
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
inline void SoftwareSerial::handleInterrupt(HardwareTimer*) {
|
|
||||||
if (active_in) active_in->recv();
|
|
||||||
if (active_out) active_out->send();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Constructor
|
|
||||||
//
|
|
||||||
SoftwareSerial::SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic /* = false */) :
|
|
||||||
_receivePin(receivePin),
|
|
||||||
_transmitPin(transmitPin),
|
|
||||||
_receivePinPort(digitalPinToPort(receivePin)),
|
|
||||||
_receivePinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(receivePin))),
|
|
||||||
_transmitPinPort(digitalPinToPort(transmitPin)),
|
|
||||||
_transmitPinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(transmitPin))),
|
|
||||||
_speed(0),
|
|
||||||
_buffer_overflow(false),
|
|
||||||
_inverse_logic(inverse_logic),
|
|
||||||
_half_duplex(receivePin == transmitPin),
|
|
||||||
_output_pending(0),
|
|
||||||
_receive_buffer_tail(0),
|
|
||||||
_receive_buffer_head(0)
|
|
||||||
{
|
|
||||||
if ((receivePin < NUM_DIGITAL_PINS) || (transmitPin < NUM_DIGITAL_PINS)) {
|
|
||||||
/* Enable GPIO clock for tx and rx pin*/
|
|
||||||
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(transmitPin)));
|
|
||||||
set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(receivePin)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_Error_Handler("ERROR: invalid pin number\n", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Destructor
|
|
||||||
//
|
|
||||||
SoftwareSerial::~SoftwareSerial() { end(); }
|
|
||||||
|
|
||||||
//
|
|
||||||
// Public methods
|
|
||||||
//
|
|
||||||
|
|
||||||
void SoftwareSerial::begin(long speed) {
|
|
||||||
#ifdef FORCE_BAUD_RATE
|
|
||||||
speed = FORCE_BAUD_RATE;
|
|
||||||
#endif
|
|
||||||
_speed = speed;
|
|
||||||
if (!_half_duplex) {
|
|
||||||
setTX();
|
|
||||||
setRX();
|
|
||||||
listen();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
setTX();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SoftwareSerial::end() {
|
|
||||||
stopListening();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read data from buffer
|
|
||||||
int SoftwareSerial::read() {
|
|
||||||
// Empty buffer?
|
|
||||||
if (_receive_buffer_head == _receive_buffer_tail) return -1;
|
|
||||||
|
|
||||||
// Read from "head"
|
|
||||||
uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
|
|
||||||
_receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SoftwareSerial::available() {
|
|
||||||
return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SoftwareSerial::write(uint8_t b) {
|
|
||||||
// wait for previous transmit to complete
|
|
||||||
_output_pending = 1;
|
|
||||||
while (active_out) { /* nada */ }
|
|
||||||
// add start and stop bits.
|
|
||||||
tx_buffer = b << 1 | 0x200;
|
|
||||||
if (_inverse_logic) tx_buffer = ~tx_buffer;
|
|
||||||
tx_bit_cnt = 0;
|
|
||||||
tx_tick_cnt = OVERSAMPLE;
|
|
||||||
setSpeed(_speed);
|
|
||||||
if (_half_duplex) setRXTX(false);
|
|
||||||
_output_pending = 0;
|
|
||||||
// make us active
|
|
||||||
active_out = this;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SoftwareSerial::flush() {
|
|
||||||
noInterrupts();
|
|
||||||
_receive_buffer_head = _receive_buffer_tail = 0;
|
|
||||||
interrupts();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SoftwareSerial::peek() {
|
|
||||||
// Empty buffer?
|
|
||||||
if (_receive_buffer_head == _receive_buffer_tail) return -1;
|
|
||||||
|
|
||||||
// Read from "head"
|
|
||||||
return _receive_buffer[_receive_buffer_head];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
|
@ -1,114 +0,0 @@
|
|||||||
/**
|
|
||||||
* SoftwareSerial.h (formerly NewSoftSerial.h)
|
|
||||||
*
|
|
||||||
* Multi-instance software serial library for Arduino/Wiring
|
|
||||||
* -- Interrupt-driven receive and other improvements by ladyada
|
|
||||||
* (https://ladyada.net)
|
|
||||||
* -- Tuning, circular buffer, derivation from class Print/Stream,
|
|
||||||
* multi-instance support, porting to 8MHz processors,
|
|
||||||
* various optimizations, PROGMEM delay tables, inverse logic and
|
|
||||||
* direct port writing by Mikal Hart (http://www.arduiniana.org)
|
|
||||||
* -- Pin change interrupt macros by Paul Stoffregen (https://www.pjrc.com)
|
|
||||||
* -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
|
|
||||||
* -- ATmega1280/2560 support by Brett Hagman (https://www.roguerobotics.com/)
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* The latest version of this library can always be found at
|
|
||||||
* http://arduiniana.org.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Definitions
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#define _SS_MAX_RX_BUFF 64 // RX buffer size
|
|
||||||
|
|
||||||
class SoftwareSerial : public Stream {
|
|
||||||
private:
|
|
||||||
// per object data
|
|
||||||
uint16_t _receivePin;
|
|
||||||
uint16_t _transmitPin;
|
|
||||||
GPIO_TypeDef *_receivePinPort;
|
|
||||||
uint32_t _receivePinNumber;
|
|
||||||
GPIO_TypeDef *_transmitPinPort;
|
|
||||||
uint32_t _transmitPinNumber;
|
|
||||||
uint32_t _speed;
|
|
||||||
|
|
||||||
uint16_t _buffer_overflow: 1;
|
|
||||||
uint16_t _inverse_logic: 1;
|
|
||||||
uint16_t _half_duplex: 1;
|
|
||||||
uint16_t _output_pending: 1;
|
|
||||||
|
|
||||||
unsigned char _receive_buffer[_SS_MAX_RX_BUFF];
|
|
||||||
volatile uint8_t _receive_buffer_tail;
|
|
||||||
volatile uint8_t _receive_buffer_head;
|
|
||||||
|
|
||||||
uint32_t delta_start = 0;
|
|
||||||
|
|
||||||
// static data
|
|
||||||
static HardwareTimer timer;
|
|
||||||
static const IRQn_Type timer_interrupt_number;
|
|
||||||
static uint32_t timer_interrupt_priority;
|
|
||||||
static SoftwareSerial *active_listener;
|
|
||||||
static SoftwareSerial *volatile active_out;
|
|
||||||
static SoftwareSerial *volatile active_in;
|
|
||||||
static int32_t tx_tick_cnt;
|
|
||||||
static volatile int32_t rx_tick_cnt;
|
|
||||||
static uint32_t tx_buffer;
|
|
||||||
static int32_t tx_bit_cnt;
|
|
||||||
static uint32_t rx_buffer;
|
|
||||||
static int32_t rx_bit_cnt;
|
|
||||||
static uint32_t cur_speed;
|
|
||||||
|
|
||||||
// private methods
|
|
||||||
void send();
|
|
||||||
void recv();
|
|
||||||
void setTX();
|
|
||||||
void setRX();
|
|
||||||
void setSpeed(uint32_t speed);
|
|
||||||
void setRXTX(bool input);
|
|
||||||
static void handleInterrupt(HardwareTimer *timer);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// public methods
|
|
||||||
|
|
||||||
SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic=false);
|
|
||||||
virtual ~SoftwareSerial();
|
|
||||||
void begin(long speed);
|
|
||||||
bool listen();
|
|
||||||
void end();
|
|
||||||
bool isListening() { return active_listener == this; }
|
|
||||||
bool stopListening();
|
|
||||||
bool overflow() {
|
|
||||||
bool ret = _buffer_overflow;
|
|
||||||
if (ret) _buffer_overflow = false;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
int peek();
|
|
||||||
|
|
||||||
virtual size_t write(uint8_t byte);
|
|
||||||
virtual int read();
|
|
||||||
virtual int available();
|
|
||||||
virtual void flush();
|
|
||||||
operator bool() { return true; }
|
|
||||||
|
|
||||||
static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
|
|
||||||
|
|
||||||
using Print::write;
|
|
||||||
};
|
|
@ -98,7 +98,7 @@ static inline void pwm_details(const pin_t pin) {
|
|||||||
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
||||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||||
const char num = (
|
const char num = (
|
||||||
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
tdev == &timer8 ? '8' :
|
tdev == &timer8 ? '8' :
|
||||||
tdev == &timer5 ? '5' :
|
tdev == &timer5 ? '5' :
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,7 +87,7 @@ void TFT_FSMC::Init() {
|
|||||||
|
|
||||||
__HAL_RCC_FSMC_CLK_ENABLE();
|
__HAL_RCC_FSMC_CLK_ENABLE();
|
||||||
|
|
||||||
for(uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++)
|
for (uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++)
|
||||||
pinmap_pinout(PinMap_FSMC[i].pin, PinMap_FSMC);
|
pinmap_pinout(PinMap_FSMC[i].pin, PinMap_FSMC);
|
||||||
pinmap_pinout(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
|
pinmap_pinout(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
|
||||||
pinmap_pinout(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS);
|
pinmap_pinout(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS);
|
||||||
|
@ -155,9 +155,9 @@ uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) {
|
|||||||
|
|
||||||
uint16_t XPT2046::HardwareIO(uint16_t data) {
|
uint16_t XPT2046::HardwareIO(uint16_t data) {
|
||||||
__HAL_SPI_ENABLE(&SPIx);
|
__HAL_SPI_ENABLE(&SPIx);
|
||||||
while((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
|
||||||
SPIx.Instance->DR = data;
|
SPIx.Instance->DR = data;
|
||||||
while((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
|
while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {}
|
||||||
__HAL_SPI_DISABLE(&SPIx);
|
__HAL_SPI_DISABLE(&SPIx);
|
||||||
|
|
||||||
return SPIx.Instance->DR;
|
return SPIx.Instance->DR;
|
||||||
|
@ -110,7 +110,6 @@
|
|||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
|
HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
|
||||||
bool timer_enabled[NUM_HARDWARE_TIMERS] = { false };
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Public functions
|
// Public functions
|
||||||
@ -135,6 +134,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
|||||||
* which changes the prescaler when an IRQ frequency change is needed
|
* which changes the prescaler when an IRQ frequency change is needed
|
||||||
* (for example when steppers are turned on)
|
* (for example when steppers are turned on)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
|
timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
|
||||||
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
|
timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
|
||||||
break;
|
break;
|
||||||
@ -145,15 +145,13 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable preload. Leaving it default-enabled can cause the timer to stop if it happens
|
||||||
|
// to exit the ISR after the start time for the next interrupt has already passed.
|
||||||
|
timer_instance[timer_num]->setPreloadEnable(false);
|
||||||
|
|
||||||
HAL_timer_enable_interrupt(timer_num);
|
HAL_timer_enable_interrupt(timer_num);
|
||||||
|
|
||||||
/*
|
// Start the timer.
|
||||||
* Initializes (and unfortunately starts) the timer.
|
|
||||||
* This is needed to set correct IRQ priority at the moment but causes
|
|
||||||
* no harm since every call to HAL_timer_start() is actually followed by
|
|
||||||
* a call to HAL_timer_enable_interrupt() which means that there isn't
|
|
||||||
* a case in which you want the timer to run without a callback.
|
|
||||||
*/
|
|
||||||
timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
|
timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
|
||||||
|
|
||||||
// This is fixed in Arduino_Core_STM32 1.8.
|
// This is fixed in Arduino_Core_STM32 1.8.
|
||||||
@ -161,18 +159,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
|||||||
// timer_instance[timer_num]->setInterruptPriority
|
// timer_instance[timer_num]->setInterruptPriority
|
||||||
switch (timer_num) {
|
switch (timer_num) {
|
||||||
case STEP_TIMER_NUM:
|
case STEP_TIMER_NUM:
|
||||||
HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0);
|
timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
|
||||||
break;
|
break;
|
||||||
case TEMP_TIMER_NUM:
|
case TEMP_TIMER_NUM:
|
||||||
HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_NAME, TEMP_TIMER_IRQ_PRIO, 0);
|
timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||||
if (HAL_timer_initialized(timer_num) && !timer_enabled[timer_num]) {
|
if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
|
||||||
timer_enabled[timer_num] = true;
|
|
||||||
switch (timer_num) {
|
switch (timer_num) {
|
||||||
case STEP_TIMER_NUM:
|
case STEP_TIMER_NUM:
|
||||||
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
timer_instance[timer_num]->attachInterrupt(Step_Handler);
|
||||||
@ -185,23 +182,11 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||||
if (HAL_timer_interrupt_enabled(timer_num)) {
|
if (HAL_timer_initialized(timer_num)) timer_instance[timer_num]->detachInterrupt();
|
||||||
timer_instance[timer_num]->detachInterrupt();
|
|
||||||
timer_enabled[timer_num] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||||
return HAL_timer_initialized(timer_num) && timer_enabled[timer_num];
|
return HAL_timer_initialized(timer_num) && timer_instance[timer_num]->hasInterrupt();
|
||||||
}
|
|
||||||
|
|
||||||
// Only for use within the HAL
|
|
||||||
TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
|
|
||||||
switch (timer_num) {
|
|
||||||
case STEP_TIMER_NUM: return STEP_TIMER_DEV;
|
|
||||||
case TEMP_TIMER_NUM: return TEMP_TIMER_DEV;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTimerInterruptPriorities() {
|
void SetTimerInterruptPriorities() {
|
||||||
@ -209,4 +194,87 @@ void SetTimerInterruptPriorities() {
|
|||||||
TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
|
TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a terrible hack to replicate the behavior used in the framework's SoftwareSerial.cpp
|
||||||
|
// to choose a serial timer. It will select TIM7 on most boards used by Marlin, but this is more
|
||||||
|
// resiliant to new MCUs which may not have a TIM7. Best practice is to explicitly specify
|
||||||
|
// TIMER_SERIAL to avoid relying on framework selections which may not be predictable.
|
||||||
|
#if !defined(TIMER_SERIAL)
|
||||||
|
#if defined (TIM18_BASE)
|
||||||
|
#define TIMER_SERIAL TIM18
|
||||||
|
#elif defined (TIM7_BASE)
|
||||||
|
#define TIMER_SERIAL TIM7
|
||||||
|
#elif defined (TIM6_BASE)
|
||||||
|
#define TIMER_SERIAL TIM6
|
||||||
|
#elif defined (TIM22_BASE)
|
||||||
|
#define TIMER_SERIAL TIM22
|
||||||
|
#elif defined (TIM21_BASE)
|
||||||
|
#define TIMER_SERIAL TIM21
|
||||||
|
#elif defined (TIM17_BASE)
|
||||||
|
#define TIMER_SERIAL TIM17
|
||||||
|
#elif defined (TIM16_BASE)
|
||||||
|
#define TIMER_SERIAL TIM16
|
||||||
|
#elif defined (TIM15_BASE)
|
||||||
|
#define TIMER_SERIAL TIM15
|
||||||
|
#elif defined (TIM14_BASE)
|
||||||
|
#define TIMER_SERIAL TIM14
|
||||||
|
#elif defined (TIM13_BASE)
|
||||||
|
#define TIMER_SERIAL TIM13
|
||||||
|
#elif defined (TIM11_BASE)
|
||||||
|
#define TIMER_SERIAL TIM11
|
||||||
|
#elif defined (TIM10_BASE)
|
||||||
|
#define TIMER_SERIAL TIM10
|
||||||
|
#elif defined (TIM12_BASE)
|
||||||
|
#define TIMER_SERIAL TIM12
|
||||||
|
#elif defined (TIM19_BASE)
|
||||||
|
#define TIMER_SERIAL TIM19
|
||||||
|
#elif defined (TIM9_BASE)
|
||||||
|
#define TIMER_SERIAL TIM9
|
||||||
|
#elif defined (TIM5_BASE)
|
||||||
|
#define TIMER_SERIAL TIM5
|
||||||
|
#elif defined (TIM4_BASE)
|
||||||
|
#define TIMER_SERIAL TIM4
|
||||||
|
#elif defined (TIM3_BASE)
|
||||||
|
#define TIMER_SERIAL TIM3
|
||||||
|
#elif defined (TIM2_BASE)
|
||||||
|
#define TIMER_SERIAL TIM2
|
||||||
|
#elif defined (TIM20_BASE)
|
||||||
|
#define TIMER_SERIAL TIM20
|
||||||
|
#elif defined (TIM8_BASE)
|
||||||
|
#define TIMER_SERIAL TIM8
|
||||||
|
#elif defined (TIM1_BASE)
|
||||||
|
#define TIMER_SERIAL TIM1
|
||||||
|
#else
|
||||||
|
#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Place all timers used into an array, then recursively check for duplicates during compilation.
|
||||||
|
// This does not currently account for timers used for PWM, such as for fans.
|
||||||
|
// Timers are actually pointers. Convert to integers to simplify constexpr logic.
|
||||||
|
static constexpr uintptr_t timers_in_use[] = {
|
||||||
|
uintptr_t(TEMP_TIMER_DEV), // Override in pins file
|
||||||
|
uintptr_t(STEP_TIMER_DEV), // Override in pins file
|
||||||
|
#if HAS_TMC_SW_SERIAL
|
||||||
|
uintptr_t(TIMER_SERIAL), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||||
|
#endif
|
||||||
|
#if ENABLED(SPEAKER)
|
||||||
|
uintptr_t(TIMER_TONE), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||||
|
#endif
|
||||||
|
#if HAS_SERVOS
|
||||||
|
uintptr_t(TIMER_SERVO), // Set in variant.h, or as a define in platformio.h if not present in variant.h
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr bool verify_no_duplicate_timers() {
|
||||||
|
LOOP_L_N(i, COUNT(timers_in_use))
|
||||||
|
LOOP_S_L_N(j, i + 1, COUNT(timers_in_use))
|
||||||
|
if (timers_in_use[i] == timers_in_use[j]) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this assertion fails at compile time, review the timers_in_use array. If default_envs is
|
||||||
|
// defined properly in platformio.ini, VS Code can evaluate the array when hovering over it,
|
||||||
|
// making it easy to identify the conflicting timers.
|
||||||
|
static_assert(verify_no_duplicate_timers(), "One or more timer conflict detected");
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
||||||
|
@ -30,8 +30,18 @@
|
|||||||
|
|
||||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||||
|
|
||||||
|
// STM32 timers may be 16 or 32 bit. Limiting HAL_TIMER_TYPE_MAX to 16 bits
|
||||||
|
// avoids issues with STM32F0 MCUs, which seem to pause timers if UINT32_MAX
|
||||||
|
// is written to the register. STM32F4 timers do not manifest this issue,
|
||||||
|
// even when writing to 16 bit timers.
|
||||||
|
//
|
||||||
|
// The range of the timer can be queried at runtime using IS_TIM_32B_COUNTER_INSTANCE.
|
||||||
|
// This is a more expensive check than a simple compile-time constant, so its
|
||||||
|
// implementation is deferred until the desire for a 32-bit range outweighs the cost
|
||||||
|
// of adding a run-time check and HAL_TIMER_TYPE_MAX is refactored to allow unique
|
||||||
|
// values for each timer.
|
||||||
#define hal_timer_t uint32_t
|
#define hal_timer_t uint32_t
|
||||||
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
|
#define HAL_TIMER_TYPE_MAX UINT16_MAX
|
||||||
|
|
||||||
#ifndef STEP_TIMER_NUM
|
#ifndef STEP_TIMER_NUM
|
||||||
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||||
@ -61,14 +71,14 @@
|
|||||||
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
||||||
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||||
|
|
||||||
extern void Step_Handler(HardwareTimer *htim);
|
extern void Step_Handler();
|
||||||
extern void Temp_Handler(HardwareTimer *htim);
|
extern void Temp_Handler();
|
||||||
|
|
||||||
#ifndef HAL_STEP_TIMER_ISR
|
#ifndef HAL_STEP_TIMER_ISR
|
||||||
#define HAL_STEP_TIMER_ISR() void Step_Handler(HardwareTimer *htim)
|
#define HAL_STEP_TIMER_ISR() void Step_Handler()
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAL_TEMP_TIMER_ISR
|
#ifndef HAL_TEMP_TIMER_ISR
|
||||||
#define HAL_TEMP_TIMER_ISR() void Temp_Handler(HardwareTimer *htim)
|
#define HAL_TEMP_TIMER_ISR() void Temp_Handler()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@ -90,8 +100,6 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
|||||||
// Exposed here to allow all timer priority information to reside in timers.cpp
|
// Exposed here to allow all timer priority information to reside in timers.cpp
|
||||||
void SetTimerInterruptPriorities();
|
void SetTimerInterruptPriorities();
|
||||||
|
|
||||||
//TIM_TypeDef* HAL_timer_device(const uint8_t timer_num); no need to be public for now. not public = not used externally
|
|
||||||
|
|
||||||
// FORCE_INLINE because these are used in performance-critical situations
|
// FORCE_INLINE because these are used in performance-critical situations
|
||||||
FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_num) {
|
FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_num) {
|
||||||
return timer_instance[timer_num] != NULL;
|
return timer_instance[timer_num] != NULL;
|
||||||
|
@ -46,12 +46,14 @@
|
|||||||
#include "msc_sd.h"
|
#include "msc_sd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "MarlinSerial.h"
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Defines
|
// Defines
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
#ifndef STM32_FLASH_SIZE
|
#ifndef STM32_FLASH_SIZE
|
||||||
#if defined(MCU_STM32F103RE) || defined(MCU_STM32F103VE)
|
#if EITHER(MCU_STM32F103RE, MCU_STM32F103VE)
|
||||||
#define STM32_FLASH_SIZE 512
|
#define STM32_FLASH_SIZE 512
|
||||||
#else
|
#else
|
||||||
#define STM32_FLASH_SIZE 256
|
#define STM32_FLASH_SIZE 256
|
||||||
@ -64,86 +66,50 @@
|
|||||||
#else
|
#else
|
||||||
#define UsbSerial MarlinCompositeSerial
|
#define UsbSerial MarlinCompositeSerial
|
||||||
#endif
|
#endif
|
||||||
#define MSerial1 Serial1
|
|
||||||
#define MSerial2 Serial2
|
|
||||||
#define MSerial3 Serial3
|
|
||||||
#define MSerial4 Serial4
|
|
||||||
#define MSerial5 Serial5
|
|
||||||
#else
|
|
||||||
#define MSerial1 Serial
|
|
||||||
#define MSerial2 Serial1
|
|
||||||
#define MSerial3 Serial2
|
|
||||||
#define MSerial4 Serial3
|
|
||||||
#define MSerial5 Serial4
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SERIAL_PORT == 0
|
#define _MSERIAL(X) MSerial##X
|
||||||
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
#elif SERIAL_PORT == -1
|
|
||||||
#define MYSERIAL0 UsbSerial
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
#elif SERIAL_PORT == 1
|
#define NUM_UARTS 5
|
||||||
#define MYSERIAL0 MSerial1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 MSerial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 MSerial3
|
|
||||||
#elif SERIAL_PORT == 4
|
|
||||||
#define MYSERIAL0 MSerial4
|
|
||||||
#elif SERIAL_PORT == 5
|
|
||||||
#define MYSERIAL0 MSerial5
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 5. Please update your configuration."
|
#define NUM_UARTS 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SERIAL_PORT == -1
|
||||||
|
#define MYSERIAL0 UsbSerial
|
||||||
|
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
|
||||||
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
|
#elif NUM_UARTS == 5
|
||||||
|
#error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||||
|
#else
|
||||||
|
#error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if SERIAL_PORT_2 == 0
|
#if SERIAL_PORT_2 == -1
|
||||||
#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 UsbSerial
|
#define MYSERIAL1 UsbSerial
|
||||||
#elif SERIAL_PORT_2 == 1
|
#elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
|
||||||
#define MYSERIAL1 MSerial1
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 2
|
#elif NUM_UARTS == 5
|
||||||
#define MYSERIAL1 MSerial2
|
#error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 MSerial3
|
|
||||||
#elif SERIAL_PORT_2 == 4
|
|
||||||
#define MYSERIAL1 MSerial4
|
|
||||||
#elif SERIAL_PORT_2 == 5
|
|
||||||
#define MYSERIAL1 MSerial5
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration."
|
#error "SERIAL_PORT_2 must be -1 or from 1 to 3. 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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LCD_SERIAL_PORT
|
||||||
|
#if LCD_SERIAL_PORT == -1
|
||||||
|
#define LCD_SERIAL UsbSerial
|
||||||
|
#elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS)
|
||||||
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
|
#elif NUM_UARTS == 5
|
||||||
|
#error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
|
||||||
|
#else
|
||||||
|
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set interrupt grouping for this MCU
|
// Set interrupt grouping for this MCU
|
||||||
void HAL_init();
|
void HAL_init();
|
||||||
|
193
Marlin/src/HAL/STM32F1/MarlinSerial.cpp
Normal file
193
Marlin/src/HAL/STM32F1/MarlinSerial.cpp
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __STM32F1__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
#include "MarlinSerial.h"
|
||||||
|
#include <libmaple/usart.h>
|
||||||
|
|
||||||
|
// Copied from ~/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/usart_private.h
|
||||||
|
// Changed to handle Emergency Parser
|
||||||
|
static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb, usart_reg_map *regs, MarlinSerial &serial) {
|
||||||
|
/* Handle RXNEIE and TXEIE interrupts.
|
||||||
|
* RXNE signifies availability of a byte in DR.
|
||||||
|
*
|
||||||
|
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
|
||||||
|
* We enable RXNEIE.
|
||||||
|
*/
|
||||||
|
uint32_t srflags = regs->SR, cr1its = regs->CR1;
|
||||||
|
|
||||||
|
if ((cr1its & USART_CR1_RXNEIE) && (srflags & USART_SR_RXNE)) {
|
||||||
|
if (srflags & USART_SR_FE || srflags & USART_SR_PE ) {
|
||||||
|
// framing error or parity error
|
||||||
|
regs->DR; // Read and throw away the data, which also clears FE and PE
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint8_t c = (uint8)regs->DR;
|
||||||
|
#ifdef USART_SAFE_INSERT
|
||||||
|
// If the buffer is full and the user defines USART_SAFE_INSERT,
|
||||||
|
// ignore new bytes.
|
||||||
|
rb_safe_insert(rb, c);
|
||||||
|
#else
|
||||||
|
// By default, push bytes around in the ring buffer.
|
||||||
|
rb_push_insert(rb, c);
|
||||||
|
#endif
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
if (serial.emergency_parser_enabled())
|
||||||
|
emergency_parser.update(serial.emergency_state, c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (srflags & USART_SR_ORE) {
|
||||||
|
// overrun and empty data, just do a dummy read to clear ORE
|
||||||
|
// and prevent a raise condition where a continous interrupt stream (due to ORE set) occurs
|
||||||
|
// (see chapter "Overrun error" ) in STM32 reference manual
|
||||||
|
regs->DR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TXE signifies readiness to send a byte to DR.
|
||||||
|
if ((cr1its & USART_CR1_TXEIE) && (srflags & USART_SR_TXE)) {
|
||||||
|
if (!rb_is_empty(wb))
|
||||||
|
regs->DR=rb_remove(wb);
|
||||||
|
else
|
||||||
|
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not every MarlinSerial port should handle emergency parsing.
|
||||||
|
// It would not make sense to parse GCode from TMC responses, for example.
|
||||||
|
constexpr bool serial_handles_emergency(int port) {
|
||||||
|
return false
|
||||||
|
#ifdef SERIAL_PORT
|
||||||
|
|| (SERIAL_PORT) == port
|
||||||
|
#endif
|
||||||
|
#ifdef SERIAL_PORT_2
|
||||||
|
|| (SERIAL_PORT_2) == port
|
||||||
|
#endif
|
||||||
|
#ifdef LCD_SERIAL_PORT
|
||||||
|
|| (LCD_SERIAL_PORT) == port
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEFINE_HWSERIAL_MARLIN(name, n) \
|
||||||
|
MarlinSerial name(USART##n, \
|
||||||
|
BOARD_USART##n##_TX_PIN, \
|
||||||
|
BOARD_USART##n##_RX_PIN, \
|
||||||
|
serial_handles_emergency(n)); \
|
||||||
|
extern "C" void __irq_usart##n(void) { \
|
||||||
|
my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEFINE_HWSERIAL_UART_MARLIN(name, n) \
|
||||||
|
MarlinSerial name(UART##n, \
|
||||||
|
BOARD_USART##n##_TX_PIN, \
|
||||||
|
BOARD_USART##n##_RX_PIN, \
|
||||||
|
serial_handles_emergency(n)); \
|
||||||
|
extern "C" void __irq_usart##n(void) { \
|
||||||
|
my_usart_irq(UART##n->rb, UART##n->wb, UART##n##_BASE, MSerial##n); \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instantiate all UARTs even if they are not needed
|
||||||
|
// This avoids a bunch of logic to figure out every serial
|
||||||
|
// port which may be in use on the system.
|
||||||
|
DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
|
||||||
|
DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
|
||||||
|
DEFINE_HWSERIAL_MARLIN(MSerial3, 3);
|
||||||
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
|
DEFINE_HWSERIAL_UART_MARLIN(MSerial4, 4);
|
||||||
|
DEFINE_HWSERIAL_UART_MARLIN(MSerial5, 5);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Check the type of each serial port by passing it to a template function.
|
||||||
|
// HardwareSerial is known to sometimes hang the controller when an error occurs,
|
||||||
|
// so this case will fail the static assert. All other classes are assumed to be ok.
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool IsSerialClassAllowed(const T&) { return true; }
|
||||||
|
constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; }
|
||||||
|
|
||||||
|
#define CHECK_CFG_SERIAL(A) static_assert(IsSerialClassAllowed(A), STRINGIFY(A) " is defined incorrectly");
|
||||||
|
#define CHECK_AXIS_SERIAL(A) static_assert(IsSerialClassAllowed(A##_HARDWARE_SERIAL), STRINGIFY(A) "_HARDWARE_SERIAL must be defined in the form MSerial1, rather than Serial1");
|
||||||
|
|
||||||
|
// If you encounter this error, replace SerialX with MSerialX, for example MSerial3.
|
||||||
|
|
||||||
|
// Non-TMC ports were already validated in HAL.h, so do not require verbose error messages.
|
||||||
|
#ifdef MYSERIAL0
|
||||||
|
CHECK_CFG_SERIAL(MYSERIAL0);
|
||||||
|
#endif
|
||||||
|
#ifdef MYSERIAL1
|
||||||
|
CHECK_CFG_SERIAL(MYSERIAL1);
|
||||||
|
#endif
|
||||||
|
#ifdef LCD_SERIAL
|
||||||
|
CHECK_CFG_SERIAL(LCD_SERIAL);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(X)
|
||||||
|
CHECK_AXIS_SERIAL(X);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(X2)
|
||||||
|
CHECK_AXIS_SERIAL(X2);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Y)
|
||||||
|
CHECK_AXIS_SERIAL(Y);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Y2)
|
||||||
|
CHECK_AXIS_SERIAL(Y2);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Z)
|
||||||
|
CHECK_AXIS_SERIAL(Z);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Z2)
|
||||||
|
CHECK_AXIS_SERIAL(Z2);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Z3)
|
||||||
|
CHECK_AXIS_SERIAL(Z3);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(Z4)
|
||||||
|
CHECK_AXIS_SERIAL(Z4);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E0)
|
||||||
|
CHECK_AXIS_SERIAL(E0);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E1)
|
||||||
|
CHECK_AXIS_SERIAL(E1);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E2)
|
||||||
|
CHECK_AXIS_SERIAL(E2);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E3)
|
||||||
|
CHECK_AXIS_SERIAL(E3);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E4)
|
||||||
|
CHECK_AXIS_SERIAL(E4);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E5)
|
||||||
|
CHECK_AXIS_SERIAL(E5);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E6)
|
||||||
|
CHECK_AXIS_SERIAL(E6);
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_HW_SERIAL(E7)
|
||||||
|
CHECK_AXIS_SERIAL(E7);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __STM32F1__
|
71
Marlin/src/HAL/STM32F1/MarlinSerial.h
Normal file
71
Marlin/src/HAL/STM32F1/MarlinSerial.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <HardwareSerial.h>
|
||||||
|
#include <libmaple/usart.h>
|
||||||
|
#include <WString.h>
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
#include "../../feature/e_parser.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Increase priority of serial interrupts, to reduce overflow errors
|
||||||
|
#define UART_IRQ_PRIO 1
|
||||||
|
|
||||||
|
class MarlinSerial : public HardwareSerial {
|
||||||
|
public:
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
const bool ep_enabled;
|
||||||
|
EmergencyParser::State emergency_state;
|
||||||
|
inline bool emergency_parser_enabled() { return ep_enabled; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin, bool TERN_(EMERGENCY_PARSER, ep_capable)) :
|
||||||
|
HardwareSerial(usart_device, tx_pin, rx_pin)
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
, ep_enabled(ep_capable)
|
||||||
|
, emergency_state(EmergencyParser::State::EP_RESET)
|
||||||
|
#endif
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#ifdef UART_IRQ_PRIO
|
||||||
|
// Shadow the parent methods to set IRQ priority after begin()
|
||||||
|
void begin(uint32 baud) {
|
||||||
|
MarlinSerial::begin(baud, SERIAL_8N1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void begin(uint32 baud, uint8_t config) {
|
||||||
|
HardwareSerial::begin(baud, config);
|
||||||
|
nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MarlinSerial MSerial1;
|
||||||
|
extern MarlinSerial MSerial2;
|
||||||
|
extern MarlinSerial MSerial3;
|
||||||
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
|
extern MarlinSerial MSerial4;
|
||||||
|
extern MarlinSerial MSerial5;
|
||||||
|
#endif
|
@ -40,6 +40,9 @@
|
|||||||
#include <boards.h>
|
#include <boards.h>
|
||||||
#include <wirish.h>
|
#include <wirish.h>
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
#include "spi_pins.h"
|
||||||
|
|
||||||
/** Time in ms for DMA receive timeout */
|
/** Time in ms for DMA receive timeout */
|
||||||
#define DMA_TIMEOUT 100
|
#define DMA_TIMEOUT 100
|
||||||
|
|
||||||
@ -710,6 +713,6 @@ static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq) {
|
|||||||
return baud_rates[i];
|
return baud_rates[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIClass SPI(1);
|
SPIClass SPI(SPI_DEVICE);
|
||||||
|
|
||||||
#endif // __STM32F1__
|
#endif // __STM32F1__
|
||||||
|
@ -57,4 +57,4 @@ void SoftwareSerial::stopListening() {
|
|||||||
listening = false;
|
listening = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //__STM32F1__
|
#endif // __STM32F1__
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "../../../inc/MarlinConfig.h"
|
#include "../../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if BOTH(HAS_GRAPHICAL_LCD, FORCE_SOFT_SPI)
|
#if BOTH(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI)
|
||||||
|
|
||||||
#include "../HAL.h"
|
#include "../HAL.h"
|
||||||
#include <U8glib.h>
|
#include <U8glib.h>
|
||||||
@ -161,5 +161,5 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_GRAPHICAL_LCD
|
#endif // HAS_MARLINUI_U8GLIB
|
||||||
#endif // STM32F1
|
#endif // STM32F1
|
||||||
|
@ -25,10 +25,6 @@
|
|||||||
* Test STM32F1-specific configuration values for errors at compile-time.
|
* Test STM32F1-specific configuration values for errors at compile-time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLED(EMERGENCY_PARSER)
|
|
||||||
#error "EMERGENCY_PARSER is not yet implemented for STM32F1. Disable EMERGENCY_PARSER to continue."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on STM32F1."
|
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on STM32F1."
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define PRODUCT_ID 0x29
|
#define PRODUCT_ID 0x29
|
||||||
|
|
||||||
USBMassStorage MarlinMSC;
|
USBMassStorage MarlinMSC;
|
||||||
USBCompositeSerial MarlinCompositeSerial;
|
MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
@ -38,6 +38,17 @@ USBCompositeSerial MarlinCompositeSerial;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
void (*real_rx_callback)(void);
|
||||||
|
|
||||||
|
void my_rx_callback(void) {
|
||||||
|
real_rx_callback();
|
||||||
|
int len = MarlinCompositeSerial.available();
|
||||||
|
while (len-- > 0) // >0 because available() may return a negative value
|
||||||
|
emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MSC_SD_init() {
|
void MSC_SD_init() {
|
||||||
USBComposite.setProductId(PRODUCT_ID);
|
USBComposite.setProductId(PRODUCT_ID);
|
||||||
// Just set MarlinCompositeSerial enabled to true
|
// Just set MarlinCompositeSerial enabled to true
|
||||||
@ -59,6 +70,11 @@ void MSC_SD_init() {
|
|||||||
// Register composite Serial
|
// Register composite Serial
|
||||||
MarlinCompositeSerial.registerComponent();
|
MarlinCompositeSerial.registerComponent();
|
||||||
USBComposite.begin();
|
USBComposite.begin();
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
//rx is usbSerialPart.endpoints[2]
|
||||||
|
real_rx_callback = usbSerialPart.endpoints[2].callback;
|
||||||
|
usbSerialPart.endpoints[2].callback = my_rx_callback;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_USB_COMPOSITE
|
#endif // USE_USB_COMPOSITE
|
||||||
|
@ -17,7 +17,26 @@
|
|||||||
|
|
||||||
#include <USBComposite.h>
|
#include <USBComposite.h>
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
#include "../../feature/e_parser.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class MarlinUSBCompositeSerial : public USBCompositeSerial {
|
||||||
|
public:
|
||||||
|
MarlinUSBCompositeSerial() : USBCompositeSerial()
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
, emergency_state(EmergencyParser::State::EP_RESET)
|
||||||
|
#endif
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
EmergencyParser::State emergency_state;
|
||||||
|
inline bool emergency_parser_enabled() { return true; }
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
extern USBMassStorage MarlinMSC;
|
extern USBMassStorage MarlinMSC;
|
||||||
extern USBCompositeSerial MarlinCompositeSerial;
|
extern MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||||
|
|
||||||
void MSC_SD_init();
|
void MSC_SD_init();
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
* No restriction on use. You can use, modify and redistribute it for
|
* No restriction on use. You can use, modify and redistribute it for
|
||||||
* personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
* personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
||||||
* Redistributions of source code must retain the above copyright notice.
|
* Redistributions of source code must retain the above copyright notice.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
@ -21,23 +20,23 @@
|
|||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
|
|
||||||
#if HAS_SHARED_MEDIA
|
#if HAS_SHARED_MEDIA
|
||||||
#ifndef ON_BOARD_SPI_DEVICE
|
#ifndef ONBOARD_SPI_DEVICE
|
||||||
#define ON_BOARD_SPI_DEVICE SPI_DEVICE
|
#define ONBOARD_SPI_DEVICE SPI_DEVICE
|
||||||
#endif
|
#endif
|
||||||
#define ONBOARD_SD_SPI SPI
|
#define ONBOARD_SD_SPI SPI
|
||||||
#else
|
#else
|
||||||
SPIClass OnBoardSPI(ON_BOARD_SPI_DEVICE);
|
SPIClass OnboardSPI(ONBOARD_SPI_DEVICE);
|
||||||
#define ONBOARD_SD_SPI OnBoardSPI
|
#define ONBOARD_SD_SPI OnboardSPI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ON_BOARD_SPI_DEVICE == 1
|
#if ONBOARD_SPI_DEVICE == 1
|
||||||
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_4
|
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_4
|
||||||
#else
|
#else
|
||||||
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2
|
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnBoardSPI cs low */
|
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnboardSPI cs low */
|
||||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnBoardSPI cs high */
|
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnboardSPI cs high */
|
||||||
|
|
||||||
#define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX)
|
#define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX)
|
||||||
#define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256)
|
#define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256)
|
||||||
@ -152,7 +151,7 @@ static int select() { /* 1:OK, 0:Timeout */
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void power_on() { /* Enable SSP module and attach it to I/O pads */
|
static void power_on() { /* Enable SSP module and attach it to I/O pads */
|
||||||
ONBOARD_SD_SPI.setModule(ON_BOARD_SPI_DEVICE);
|
ONBOARD_SD_SPI.setModule(ONBOARD_SPI_DEVICE);
|
||||||
ONBOARD_SD_SPI.begin();
|
ONBOARD_SD_SPI.begin();
|
||||||
ONBOARD_SD_SPI.setBitOrder(MSBFIRST);
|
ONBOARD_SD_SPI.setBitOrder(MSBFIRST);
|
||||||
ONBOARD_SD_SPI.setDataMode(SPI_MODE0);
|
ONBOARD_SD_SPI.setDataMode(SPI_MODE0);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
|
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
|
||||||
|
|
||||||
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
|
#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
|
||||||
|
|
||||||
#include "sdio.h"
|
#include "sdio.h"
|
||||||
|
|
||||||
|
@ -89,6 +89,16 @@ void TFT_FSMC::Init() {
|
|||||||
uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN;
|
uint8_t cs = FSMC_CS_PIN, rs = FSMC_RS_PIN;
|
||||||
uint32_t controllerAddress;
|
uint32_t controllerAddress;
|
||||||
|
|
||||||
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
|
OUT_WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(LCD_USE_DMA_FSMC)
|
||||||
|
dma_init(FSMC_DMA_DEV);
|
||||||
|
dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL);
|
||||||
|
dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if PIN_EXISTS(TFT_RESET)
|
#if PIN_EXISTS(TFT_RESET)
|
||||||
OUT_WRITE(TFT_RESET_PIN, HIGH);
|
OUT_WRITE(TFT_RESET_PIN, HIGH);
|
||||||
delay(100);
|
delay(100);
|
||||||
@ -201,6 +211,8 @@ uint32_t TFT_FSMC::GetID() {
|
|||||||
id = ReadID(LCD_READ_ID);
|
id = ReadID(LCD_READ_ID);
|
||||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||||
id = ReadID(LCD_READ_ID4);
|
id = ReadID(LCD_READ_ID4);
|
||||||
|
if ((id & 0xFF00) == 0 && (id & 0xFF) != 0)
|
||||||
|
id = ReadID(LCD_READ_ID4);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,24 +46,16 @@
|
|||||||
// Serial override
|
// Serial override
|
||||||
//extern HalSerial usb_serial;
|
//extern HalSerial usb_serial;
|
||||||
|
|
||||||
|
#define _MSERIAL(X) SerialUART##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define SerialUART0 Serial1
|
||||||
|
|
||||||
#if defined(STM32F4) && SERIAL_PORT == 0
|
#if defined(STM32F4) && SERIAL_PORT == 0
|
||||||
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||||
#elif SERIAL_PORT == -1
|
#elif SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 SerialUSB
|
#define MYSERIAL0 SerialUSB
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 6)
|
||||||
#define MYSERIAL0 Serial1
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 SerialUART1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 SerialUART2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 SerialUART3
|
|
||||||
#elif SERIAL_PORT == 4
|
|
||||||
#define MYSERIAL0 SerialUART4
|
|
||||||
#elif SERIAL_PORT == 5
|
|
||||||
#define MYSERIAL0 SerialUART5
|
|
||||||
#elif SERIAL_PORT == 6
|
|
||||||
#define MYSERIAL0 SerialUART6
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
#error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
@ -71,57 +63,24 @@
|
|||||||
#ifdef SERIAL_PORT_2
|
#ifdef SERIAL_PORT_2
|
||||||
#if defined(STM32F4) && SERIAL_PORT_2 == 0
|
#if defined(STM32F4) && SERIAL_PORT_2 == 0
|
||||||
#error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
#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
|
#elif SERIAL_PORT_2 == -1
|
||||||
#define MYSERIAL1 SerialUSB
|
#define MYSERIAL1 SerialUSB
|
||||||
#elif SERIAL_PORT_2 == 0
|
#elif WITHIN(SERIAL_PORT_2, 0, 6)
|
||||||
#define MYSERIAL1 Serial1
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
#elif SERIAL_PORT_2 == 1
|
|
||||||
#define MYSERIAL1 SerialUART1
|
|
||||||
#elif SERIAL_PORT_2 == 2
|
|
||||||
#define MYSERIAL1 SerialUART2
|
|
||||||
#elif SERIAL_PORT_2 == 3
|
|
||||||
#define MYSERIAL1 SerialUART3
|
|
||||||
#elif SERIAL_PORT_2 == 4
|
|
||||||
#define MYSERIAL1 SerialUART4
|
|
||||||
#elif SERIAL_PORT_2 == 5
|
|
||||||
#define MYSERIAL1 SerialUART5
|
|
||||||
#elif SERIAL_PORT_2 == 6
|
|
||||||
#define MYSERIAL1 SerialUART6
|
|
||||||
#else
|
#else
|
||||||
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
|
#error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#define NUM_SERIAL 2
|
|
||||||
#else
|
|
||||||
#define NUM_SERIAL 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DGUS_SERIAL_PORT
|
#ifdef LCD_SERIAL_PORT
|
||||||
#if defined(STM32F4) && DGUS_SERIAL_PORT == 0
|
#if defined(STM32F4) && LCD_SERIAL_PORT == 0
|
||||||
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
#error "LCD_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
|
||||||
#elif DGUS_SERIAL_PORT == SERIAL_PORT
|
#elif LCD_SERIAL_PORT == -1
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
|
#define LCD_SERIAL SerialUSB
|
||||||
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
|
#elif WITHIN(LCD_SERIAL_PORT, 0, 6)
|
||||||
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
|
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||||
#elif DGUS_SERIAL_PORT == -1
|
|
||||||
#define DGUS_SERIAL SerialUSB
|
|
||||||
#elif DGUS_SERIAL_PORT == 0
|
|
||||||
#define DGUS_SERIAL Serial1
|
|
||||||
#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
|
#else
|
||||||
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
#error "LCD_SERIAL_PORT must be from -1 to 6. Please update your configuration."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ static SPISettings spiConfig;
|
|||||||
*/
|
*/
|
||||||
void spiBegin() {
|
void spiBegin() {
|
||||||
#if !defined(SS_PIN) || SS_PIN < 0
|
#if !defined(SS_PIN) || SS_PIN < 0
|
||||||
#error SS_PIN not defined!
|
#error "SS_PIN not defined!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OUT_WRITE(SS_PIN, HIGH);
|
OUT_WRITE(SS_PIN, HIGH);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(STM32GENERIC) && defined(STM32F7)
|
#if defined(STM32GENERIC) && defined(STM32F7)
|
||||||
@ -662,7 +661,6 @@ boolean TMC26XStepper::isEnabled() { return !!(chopper_config_register & T_OFF_P
|
|||||||
/**
|
/**
|
||||||
* reads a value from the TMC26X status register. The value is not obtained directly but can then
|
* reads a value from the TMC26X status register. The value is not obtained directly but can then
|
||||||
* be read by the various status routines.
|
* be read by the various status routines.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void TMC26XStepper::readStatus(char read_value) {
|
void TMC26XStepper::readStatus(char read_value) {
|
||||||
uint32_t old_driver_configuration_register_value = driver_configuration_register_value;
|
uint32_t old_driver_configuration_register_value = driver_configuration_register_value;
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -44,21 +44,19 @@
|
|||||||
//#undef MOTHERBOARD
|
//#undef MOTHERBOARD
|
||||||
//#define MOTHERBOARD BOARD_TEENSY31_32
|
//#define MOTHERBOARD BOARD_TEENSY31_32
|
||||||
|
|
||||||
#define IS_32BIT_TEENSY defined(__MK20DX256__)
|
#ifdef __MK20DX256__
|
||||||
#define IS_TEENSY32 defined(__MK20DX256__)
|
#define IS_32BIT_TEENSY 1
|
||||||
|
#define IS_TEENSY32 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NUM_SERIAL 1
|
#define _MSERIAL(X) Serial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define Serial0 Serial
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 SerialUSB
|
#define MYSERIAL0 SerialUSB
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 Serial
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 Serial1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 Serial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 Serial3
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAL_SERVO_LIB libServo
|
#define HAL_SERVO_LIB libServo
|
||||||
|
@ -45,22 +45,23 @@
|
|||||||
// Defines
|
// Defines
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
#define IS_32BIT_TEENSY (defined(__MK64FX512__) || defined(__MK66FX1M0__))
|
#ifdef __MK64FX512__
|
||||||
#define IS_TEENSY35 defined(__MK64FX512__)
|
#define IS_32BIT_TEENSY 1
|
||||||
#define IS_TEENSY36 defined(__MK66FX1M0__)
|
#define IS_TEENSY35 1
|
||||||
|
#endif
|
||||||
|
#ifdef __MK66FX1M0__
|
||||||
|
#define IS_32BIT_TEENSY 1
|
||||||
|
#define IS_TEENSY36 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NUM_SERIAL 1
|
#define _MSERIAL(X) Serial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define Serial0 Serial
|
||||||
|
|
||||||
#if SERIAL_PORT == -1
|
#if SERIAL_PORT == -1
|
||||||
#define MYSERIAL0 SerialUSB
|
#define MYSERIAL0 SerialUSB
|
||||||
#elif SERIAL_PORT == 0
|
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||||
#define MYSERIAL0 Serial
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
#elif SERIAL_PORT == 1
|
|
||||||
#define MYSERIAL0 Serial1
|
|
||||||
#elif SERIAL_PORT == 2
|
|
||||||
#define MYSERIAL0 Serial2
|
|
||||||
#elif SERIAL_PORT == 3
|
|
||||||
#define MYSERIAL0 Serial3
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAL_SERVO_LIB libServo
|
#define HAL_SERVO_LIB libServo
|
||||||
|
@ -31,7 +31,7 @@ static SPISettings spiConfig;
|
|||||||
|
|
||||||
void spiBegin() {
|
void spiBegin() {
|
||||||
#if !PIN_EXISTS(SS)
|
#if !PIN_EXISTS(SS)
|
||||||
#error SS_PIN not defined!
|
#error "SS_PIN not defined!"
|
||||||
#endif
|
#endif
|
||||||
OUT_WRITE(SS_PIN, HIGH);
|
OUT_WRITE(SS_PIN, HIGH);
|
||||||
SET_OUTPUT(SCK_PIN);
|
SET_OUTPUT(SCK_PIN);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
167
Marlin/src/HAL/TEENSY40_41/HAL.cpp
Normal file
167
Marlin/src/HAL/TEENSY40_41/HAL.cpp
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: HAL for Teensy40 (IMXRT1062)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "HAL.h"
|
||||||
|
#include "../shared/Delay.h"
|
||||||
|
#include "timers.h"
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
uint16_t HAL_adc_result, HAL_adc_select;
|
||||||
|
|
||||||
|
static const uint8_t pin2sc1a[] = {
|
||||||
|
0x07, // 0/A0 AD_B1_02
|
||||||
|
0x08, // 1/A1 AD_B1_03
|
||||||
|
0x0C, // 2/A2 AD_B1_07
|
||||||
|
0x0B, // 3/A3 AD_B1_06
|
||||||
|
0x06, // 4/A4 AD_B1_01
|
||||||
|
0x05, // 5/A5 AD_B1_00
|
||||||
|
0x0F, // 6/A6 AD_B1_10
|
||||||
|
0x00, // 7/A7 AD_B1_11
|
||||||
|
0x0D, // 8/A8 AD_B1_08
|
||||||
|
0x0E, // 9/A9 AD_B1_09
|
||||||
|
0x01, // 24/A10 AD_B0_12
|
||||||
|
0x02, // 25/A11 AD_B0_13
|
||||||
|
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||||
|
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||||
|
0x07, // 14/A0 AD_B1_02
|
||||||
|
0x08, // 15/A1 AD_B1_03
|
||||||
|
0x0C, // 16/A2 AD_B1_07
|
||||||
|
0x0B, // 17/A3 AD_B1_06
|
||||||
|
0x06, // 18/A4 AD_B1_01
|
||||||
|
0x05, // 19/A5 AD_B1_00
|
||||||
|
0x0F, // 20/A6 AD_B1_10
|
||||||
|
0x00, // 21/A7 AD_B1_11
|
||||||
|
0x0D, // 22/A8 AD_B1_08
|
||||||
|
0x0E, // 23/A9 AD_B1_09
|
||||||
|
0x01, // 24/A10 AD_B0_12
|
||||||
|
0x02, // 25/A11 AD_B0_13
|
||||||
|
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||||
|
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||||
|
#ifdef ARDUINO_TEENSY41
|
||||||
|
0xFF, // 28
|
||||||
|
0xFF, // 29
|
||||||
|
0xFF, // 30
|
||||||
|
0xFF, // 31
|
||||||
|
0xFF, // 32
|
||||||
|
0xFF, // 33
|
||||||
|
0xFF, // 34
|
||||||
|
0xFF, // 35
|
||||||
|
0xFF, // 36
|
||||||
|
0xFF, // 37
|
||||||
|
0x81, // 38/A14 AD_B1_12 - only on ADC2, 1
|
||||||
|
0x82, // 39/A15 AD_B1_13 - only on ADC2, 2
|
||||||
|
0x09, // 40/A16 AD_B1_04
|
||||||
|
0x0A, // 41/A17 AD_B1_05
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
// disable interrupts
|
||||||
|
void cli() { noInterrupts(); }
|
||||||
|
|
||||||
|
// enable interrupts
|
||||||
|
void sei() { interrupts(); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
void HAL_adc_init() {
|
||||||
|
analog_init();
|
||||||
|
while (ADC1_GC & ADC_GC_CAL) ;
|
||||||
|
while (ADC2_GC & ADC_GC_CAL) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_clear_reset_source() {
|
||||||
|
uint32_t reset_source = SRC_SRSR;
|
||||||
|
SRC_SRSR = reset_source;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t HAL_get_reset_source() {
|
||||||
|
switch (SRC_SRSR & 0xFF) {
|
||||||
|
case 1: return RST_POWER_ON; break;
|
||||||
|
case 2: return RST_SOFTWARE; break;
|
||||||
|
case 4: return RST_EXTERNAL; break;
|
||||||
|
// case 8: return RST_BROWN_OUT; break;
|
||||||
|
case 16: return RST_WATCHDOG; break;
|
||||||
|
case 64: return RST_JTAG; break;
|
||||||
|
// case 128: return RST_OVERTEMP; break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __bss_end _ebss
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern char __bss_end;
|
||||||
|
extern char __heap_start;
|
||||||
|
extern void* __brkval;
|
||||||
|
|
||||||
|
// Doesn't work on Teensy 4.x
|
||||||
|
uint32_t freeMemory() {
|
||||||
|
uint32_t free_memory;
|
||||||
|
if ((uint32_t)__brkval == 0)
|
||||||
|
free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end);
|
||||||
|
else
|
||||||
|
free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval);
|
||||||
|
return free_memory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||||
|
const uint16_t pin = pin2sc1a[adc_pin];
|
||||||
|
if (pin == 0xFF) {
|
||||||
|
HAL_adc_select = -1; // Digital only
|
||||||
|
}
|
||||||
|
else if (pin & 0x80) {
|
||||||
|
HAL_adc_select = 1;
|
||||||
|
ADC2_HC0 = pin & 0x7F;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HAL_adc_select = 0;
|
||||||
|
ADC1_HC0 = pin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t HAL_adc_get_result() {
|
||||||
|
switch (HAL_adc_select) {
|
||||||
|
case 0:
|
||||||
|
while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait
|
||||||
|
return ADC1_R0;
|
||||||
|
case 1:
|
||||||
|
while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait
|
||||||
|
return ADC2_R0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_output(uint8_t pin) {
|
||||||
|
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||||
|
p = digital_pin_to_info_PGM + pin;
|
||||||
|
return (*(p->reg + 1) & p->mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __IMXRT1062__
|
147
Marlin/src/HAL/TEENSY40_41/HAL.h
Normal file
147
Marlin/src/HAL/TEENSY40_41/HAL.h
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||||
|
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: HAL for Teensy 4.0 and Teensy 4.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CPU_32_BIT
|
||||||
|
|
||||||
|
#include "../shared/Marduino.h"
|
||||||
|
#include "../shared/math_32bit.h"
|
||||||
|
#include "../shared/HAL_SPI.h"
|
||||||
|
|
||||||
|
#include "fastio.h"
|
||||||
|
#include "watchdog.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <util/atomic.h>
|
||||||
|
|
||||||
|
//#define ST7920_DELAY_1 DELAY_NS(600)
|
||||||
|
//#define ST7920_DELAY_2 DELAY_NS(750)
|
||||||
|
//#define ST7920_DELAY_3 DELAY_NS(750)
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
|
// Defines
|
||||||
|
// ------------------------
|
||||||
|
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
#define IS_32BIT_TEENSY 1
|
||||||
|
#define IS_TEENSY41 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _MSERIAL(X) Serial##X
|
||||||
|
#define MSERIAL(X) _MSERIAL(X)
|
||||||
|
#define Serial0 Serial
|
||||||
|
|
||||||
|
#if SERIAL_PORT == -1
|
||||||
|
#define MYSERIAL0 SerialUSB
|
||||||
|
#elif WITHIN(SERIAL_PORT, 0, 8)
|
||||||
|
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
|
||||||
|
#else
|
||||||
|
#error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_2
|
||||||
|
#if SERIAL_PORT_2 == -1
|
||||||
|
#define MYSERIAL1 usbSerial
|
||||||
|
#elif WITHIN(SERIAL_PORT_2, 0, 8)
|
||||||
|
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
|
||||||
|
#else
|
||||||
|
#error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HAL_SERVO_LIB libServo
|
||||||
|
|
||||||
|
typedef int8_t pin_t;
|
||||||
|
|
||||||
|
#ifndef analogInputToDigitalPin
|
||||||
|
#define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq()
|
||||||
|
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||||
|
#define ISRS_ENABLED() (!__get_primask())
|
||||||
|
#define ENABLE_ISRS() __enable_irq()
|
||||||
|
#define DISABLE_ISRS() __disable_irq()
|
||||||
|
|
||||||
|
#undef sq
|
||||||
|
#define sq(x) ((x)*(x))
|
||||||
|
|
||||||
|
#ifndef strncpy_P
|
||||||
|
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Don't place string constants in PROGMEM
|
||||||
|
#undef PSTR
|
||||||
|
#define PSTR(str) ({static const char *data = (str); &data[0];})
|
||||||
|
|
||||||
|
// Fix bug in pgm_read_ptr
|
||||||
|
#undef pgm_read_ptr
|
||||||
|
#define pgm_read_ptr(addr) (*((void**)(addr)))
|
||||||
|
// Add type-checking to pgm_read_word
|
||||||
|
#undef pgm_read_word
|
||||||
|
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
||||||
|
|
||||||
|
// Enable hooks into idle and setup for HAL
|
||||||
|
#define HAL_IDLETASK 1
|
||||||
|
FORCE_INLINE void HAL_idletask() {}
|
||||||
|
FORCE_INLINE void HAL_init() {}
|
||||||
|
|
||||||
|
// Clear reset reason
|
||||||
|
void HAL_clear_reset_source();
|
||||||
|
|
||||||
|
// Reset reason
|
||||||
|
uint8_t HAL_get_reset_source();
|
||||||
|
|
||||||
|
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
extern "C" {
|
||||||
|
uint32_t freeMemory();
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
// ADC
|
||||||
|
|
||||||
|
void HAL_adc_init();
|
||||||
|
|
||||||
|
#define HAL_ADC_VREF 3.3
|
||||||
|
#define HAL_ADC_RESOLUTION 10
|
||||||
|
#define HAL_ADC_FILTERED // turn off ADC oversampling
|
||||||
|
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||||
|
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||||
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
|
#define HAL_ANALOG_SELECT(pin)
|
||||||
|
|
||||||
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
uint16_t HAL_adc_get_result();
|
||||||
|
|
||||||
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
||||||
|
bool is_output(uint8_t pin);
|
138
Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp
Normal file
138
Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "HAL.h"
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <pins_arduino.h>
|
||||||
|
#include "spi_pins.h"
|
||||||
|
#include "../../core/macros.h"
|
||||||
|
|
||||||
|
static SPISettings spiConfig;
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
|
// Public functions
|
||||||
|
// ------------------------
|
||||||
|
|
||||||
|
#if ENABLED(SOFTWARE_SPI)
|
||||||
|
// ------------------------
|
||||||
|
// Software SPI
|
||||||
|
// ------------------------
|
||||||
|
#error "Software SPI not supported for Teensy 4. Use Hardware SPI."
|
||||||
|
#else
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
|
// Hardware SPI
|
||||||
|
// ------------------------
|
||||||
|
|
||||||
|
void spiBegin() {
|
||||||
|
#ifndef SS_PIN
|
||||||
|
#error "SS_PIN is not defined!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OUT_WRITE(SS_PIN, HIGH);
|
||||||
|
|
||||||
|
//SET_OUTPUT(SCK_PIN);
|
||||||
|
//SET_INPUT(MISO_PIN);
|
||||||
|
//SET_OUTPUT(MOSI_PIN);
|
||||||
|
|
||||||
|
#if 0 && DISABLED(SOFTWARE_SPI)
|
||||||
|
// set SS high - may be chip select for another SPI device
|
||||||
|
#if SET_SPI_SS_HIGH
|
||||||
|
WRITE(SS_PIN, HIGH);
|
||||||
|
#endif
|
||||||
|
// set a default rate
|
||||||
|
spiInit(SPI_HALF_SPEED); // 1
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void spiInit(uint8_t spiRate) {
|
||||||
|
// Use Marlin data-rates
|
||||||
|
uint32_t clock;
|
||||||
|
switch (spiRate) {
|
||||||
|
case SPI_FULL_SPEED: clock = 10000000; break;
|
||||||
|
case SPI_HALF_SPEED: clock = 5000000; break;
|
||||||
|
case SPI_QUARTER_SPEED: clock = 2500000; break;
|
||||||
|
case SPI_EIGHTH_SPEED: clock = 1250000; break;
|
||||||
|
case SPI_SPEED_5: clock = 625000; break;
|
||||||
|
case SPI_SPEED_6: clock = 312500; break;
|
||||||
|
default:
|
||||||
|
clock = 4000000; // Default from the SPI libarary
|
||||||
|
}
|
||||||
|
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
||||||
|
SPI.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t spiRec() {
|
||||||
|
SPI.beginTransaction(spiConfig);
|
||||||
|
uint8_t returnByte = SPI.transfer(0xFF);
|
||||||
|
SPI.endTransaction();
|
||||||
|
return returnByte;
|
||||||
|
//SPDR = 0xFF;
|
||||||
|
//while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||||
|
//return SPDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
||||||
|
SPI.beginTransaction(spiConfig);
|
||||||
|
SPI.transfer(buf, nbyte);
|
||||||
|
SPI.endTransaction();
|
||||||
|
//if (nbyte-- == 0) return;
|
||||||
|
// SPDR = 0xFF;
|
||||||
|
//for (uint16_t i = 0; i < nbyte; i++) {
|
||||||
|
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||||
|
// buf[i] = SPDR;
|
||||||
|
// SPDR = 0xFF;
|
||||||
|
//}
|
||||||
|
//while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||||
|
//buf[nbyte] = SPDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spiSend(uint8_t b) {
|
||||||
|
SPI.beginTransaction(spiConfig);
|
||||||
|
SPI.transfer(b);
|
||||||
|
SPI.endTransaction();
|
||||||
|
//SPDR = b;
|
||||||
|
//while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||||
|
SPI.beginTransaction(spiConfig);
|
||||||
|
SPDR = token;
|
||||||
|
for (uint16_t i = 0; i < 512; i += 2) {
|
||||||
|
while (!TEST(SPSR, SPIF)) { /* nada */ };
|
||||||
|
SPDR = buf[i];
|
||||||
|
while (!TEST(SPSR, SPIF)) { /* nada */ };
|
||||||
|
SPDR = buf[i + 1];
|
||||||
|
}
|
||||||
|
while (!TEST(SPSR, SPIF)) { /* nada */ };
|
||||||
|
SPI.endTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Begin SPI transaction, set clock, bit order, data mode
|
||||||
|
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
|
||||||
|
spiConfig = SPISettings(spiClock, bitOrder, dataMode);
|
||||||
|
SPI.beginTransaction(spiConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SOFTWARE_SPI
|
||||||
|
#endif // __IMXRT1062__
|
57
Marlin/src/HAL/TEENSY40_41/Servo.cpp
Normal file
57
Marlin/src/HAL/TEENSY40_41/Servo.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
#if HAS_SERVOS
|
||||||
|
|
||||||
|
#include "Servo.h"
|
||||||
|
|
||||||
|
int8_t libServo::attach(const int inPin) {
|
||||||
|
if (inPin > 0) servoPin = inPin;
|
||||||
|
return super::attach(servoPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t libServo::attach(const int inPin, const int inMin, const int inMax) {
|
||||||
|
if (inPin > 0) servoPin = inPin;
|
||||||
|
return super::attach(servoPin, inMin, inMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void libServo::move(const int value) {
|
||||||
|
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
||||||
|
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
||||||
|
if (attach(0) >= 0) {
|
||||||
|
write(value);
|
||||||
|
safe_delay(servo_delay[servoIndex]);
|
||||||
|
TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void libServo::detach() {
|
||||||
|
// PWMServo library does not have detach() function
|
||||||
|
//super::detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAS_SERVOS
|
||||||
|
|
||||||
|
#endif // __IMXRT1062__
|
39
Marlin/src/HAL/TEENSY40_41/Servo.h
Normal file
39
Marlin/src/HAL/TEENSY40_41/Servo.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <PWMServo.h>
|
||||||
|
|
||||||
|
// Inherit and expand on core Servo library
|
||||||
|
class libServo : public PWMServo {
|
||||||
|
public:
|
||||||
|
int8_t attach(const int pin);
|
||||||
|
int8_t attach(const int pin, const int min, const int max);
|
||||||
|
void move(const int value);
|
||||||
|
void detach(void);
|
||||||
|
private:
|
||||||
|
typedef PWMServo super;
|
||||||
|
uint8_t servoPin;
|
||||||
|
uint16_t min_ticks;
|
||||||
|
uint16_t max_ticks;
|
||||||
|
uint8_t servoIndex; // Index into the channel data for this servo
|
||||||
|
};
|
77
Marlin/src/HAL/TEENSY40_41/eeprom.cpp
Normal file
77
Marlin/src/HAL/TEENSY40_41/eeprom.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||||
|
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||||
|
* Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
#if USE_WIRED_EEPROM
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PersistentStore for Arduino-style EEPROM interface
|
||||||
|
* with implementations supplied by the framework.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../shared/eeprom_api.h"
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
|
||||||
|
#ifndef MARLIN_EEPROM_SIZE
|
||||||
|
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
||||||
|
#endif
|
||||||
|
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||||
|
|
||||||
|
bool PersistentStore::access_start() { return true; }
|
||||||
|
bool PersistentStore::access_finish() { return true; }
|
||||||
|
|
||||||
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||||
|
while (size--) {
|
||||||
|
uint8_t * const p = (uint8_t * const)pos;
|
||||||
|
uint8_t v = *value;
|
||||||
|
// EEPROM has only ~100,000 write cycles,
|
||||||
|
// so only write bytes that have changed!
|
||||||
|
if (v != eeprom_read_byte(p)) {
|
||||||
|
eeprom_write_byte(p, v);
|
||||||
|
if (eeprom_read_byte(p) != v) {
|
||||||
|
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
crc16(crc, &v, 1);
|
||||||
|
pos++;
|
||||||
|
value++;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||||
|
do {
|
||||||
|
uint8_t c = eeprom_read_byte((uint8_t*)pos);
|
||||||
|
if (writing) *value = c;
|
||||||
|
crc16(crc, &c, 1);
|
||||||
|
pos++;
|
||||||
|
value++;
|
||||||
|
} while (--size);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_WIRED_EEPROM
|
||||||
|
#endif // __IMXRT1062__
|
66
Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h
Normal file
66
Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endstop Interrupts
|
||||||
|
*
|
||||||
|
* Without endstop interrupts the endstop pins must be polled continually in
|
||||||
|
* the temperature-ISR via endstops.update(), most of the time finding no change.
|
||||||
|
* With this feature endstops.update() is called only when we know that at
|
||||||
|
* least one endstop has changed state, saving valuable CPU cycles.
|
||||||
|
*
|
||||||
|
* This feature only works when all used endstop pins can generate an 'external interrupt'.
|
||||||
|
*
|
||||||
|
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
|
||||||
|
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../module/endstops.h"
|
||||||
|
|
||||||
|
// One ISR for all EXT-Interrupts
|
||||||
|
void endstop_ISR() { endstops.update(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endstop interrupts for Due based targets.
|
||||||
|
* On Due, all pins support external interrupt capability.
|
||||||
|
*/
|
||||||
|
void setup_endstop_interrupts() {
|
||||||
|
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
|
||||||
|
TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
|
||||||
|
TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
|
||||||
|
TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
|
||||||
|
TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
|
||||||
|
TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
|
||||||
|
TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
|
||||||
|
TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
|
||||||
|
TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
|
||||||
|
TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
|
||||||
|
TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
|
||||||
|
TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
|
||||||
|
TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
|
||||||
|
TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
|
||||||
|
TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
|
||||||
|
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||||
|
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||||
|
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||||
|
}
|
58
Marlin/src/HAL/TEENSY40_41/fastio.h
Normal file
58
Marlin/src/HAL/TEENSY40_41/fastio.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
* Copyright (c) 2017 Victor Perez
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast I/O interfaces for Teensy 4
|
||||||
|
* These use GPIO functions instead of Direct Port Manipulation, as on AVR.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PWM
|
||||||
|
#define PWM OUTPUT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define READ(IO) digitalRead(IO)
|
||||||
|
#define WRITE(IO,V) digitalWrite(IO,V)
|
||||||
|
|
||||||
|
#define _GET_MODE(IO) !is_output(IO)
|
||||||
|
#define _SET_MODE(IO,M) pinMode(IO, M)
|
||||||
|
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
|
||||||
|
|
||||||
|
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||||
|
|
||||||
|
#define SET_INPUT(IO) _SET_MODE(IO, INPUT) /*!< Input Floating Mode */
|
||||||
|
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) /*!< Input with Pull-up activation */
|
||||||
|
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
|
||||||
|
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||||
|
#define SET_PWM(IO) _SET_MODE(IO, PWM)
|
||||||
|
|
||||||
|
#define TOGGLE(IO) OUT_WRITE(IO, !READ(IO))
|
||||||
|
|
||||||
|
#define IS_INPUT(IO) !is_output(IO)
|
||||||
|
#define IS_OUTPUT(IO) is_output(IO)
|
||||||
|
|
||||||
|
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||||
|
|
||||||
|
// digitalRead/Write wrappers
|
||||||
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
26
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h
Normal file
26
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if HAS_SPI_TFT || HAS_FSMC_TFT
|
||||||
|
#error "Sorry! TFT displays are not available for HAL/TEENSY40_41."
|
||||||
|
#endif
|
22
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_adv.h
Normal file
22
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_adv.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
26
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_post.h
Normal file
26
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_post.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if USE_FALLBACK_EEPROM
|
||||||
|
#define USE_WIRED_EEPROM 1
|
||||||
|
#endif
|
38
Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h
Normal file
38
Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test TEENSY41 specific configuration values for errors at compile-time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if ENABLED(EMERGENCY_PARSER)
|
||||||
|
#error "EMERGENCY_PARSER is not yet implemented for Teensy 4.0/4.1. Disable EMERGENCY_PARSER to continue."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||||
|
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on Teensy 4.0/4.1."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAS_TMC_SW_SERIAL
|
||||||
|
#error "TMC220x Software Serial is not supported on this platform."
|
||||||
|
#endif
|
146
Marlin/src/HAL/TEENSY40_41/pinsDebug.h
Normal file
146
Marlin/src/HAL/TEENSY40_41/pinsDebug.h
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#warning "PINS_DEBUGGING is not fully supported for Teensy 4.0 / 4.1 so 'M43' may cause hangs."
|
||||||
|
|
||||||
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
|
|
||||||
|
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
||||||
|
#define PRINT_PORT(p)
|
||||||
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
||||||
|
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
|
||||||
|
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
|
||||||
|
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
|
||||||
|
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
|
||||||
|
#define pwm_status(pin) HAL_pwm_status(pin)
|
||||||
|
#define GET_PINMODE(PIN) (VALID_PIN(pin) && IS_OUTPUT(pin))
|
||||||
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
|
struct pwm_pin_info_struct {
|
||||||
|
uint8_t type; // 0=no pwm, 1=flexpwm, 2=quad
|
||||||
|
uint8_t module; // 0-3, 0-3
|
||||||
|
uint8_t channel; // 0=X, 1=A, 2=B
|
||||||
|
uint8_t muxval; //
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M(a, b) ((((a) - 1) << 4) | (b))
|
||||||
|
|
||||||
|
const struct pwm_pin_info_struct pwm_pin_info[] = {
|
||||||
|
{1, M(1, 1), 0, 4}, // FlexPWM1_1_X 0 // AD_B0_03
|
||||||
|
{1, M(1, 0), 0, 4}, // FlexPWM1_0_X 1 // AD_B0_02
|
||||||
|
{1, M(4, 2), 1, 1}, // FlexPWM4_2_A 2 // EMC_04
|
||||||
|
{1, M(4, 2), 2, 1}, // FlexPWM4_2_B 3 // EMC_05
|
||||||
|
{1, M(2, 0), 1, 1}, // FlexPWM2_0_A 4 // EMC_06
|
||||||
|
{1, M(2, 1), 1, 1}, // FlexPWM2_1_A 5 // EMC_08
|
||||||
|
{1, M(2, 2), 1, 2}, // FlexPWM2_2_A 6 // B0_10
|
||||||
|
{1, M(1, 3), 2, 6}, // FlexPWM1_3_B 7 // B1_01
|
||||||
|
{1, M(1, 3), 1, 6}, // FlexPWM1_3_A 8 // B1_00
|
||||||
|
{1, M(2, 2), 2, 2}, // FlexPWM2_2_B 9 // B0_11
|
||||||
|
{2, M(1, 0), 0, 1}, // QuadTimer1_0 10 // B0_00
|
||||||
|
{2, M(1, 2), 0, 1}, // QuadTimer1_2 11 // B0_02
|
||||||
|
{2, M(1, 1), 0, 1}, // QuadTimer1_1 12 // B0_01
|
||||||
|
{2, M(2, 0), 0, 1}, // QuadTimer2_0 13 // B0_03
|
||||||
|
{2, M(3, 2), 0, 1}, // QuadTimer3_2 14 // AD_B1_02
|
||||||
|
{2, M(3, 3), 0, 1}, // QuadTimer3_3 15 // AD_B1_03
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{2, M(3, 1), 0, 1}, // QuadTimer3_1 18 // AD_B1_01
|
||||||
|
{2, M(3, 0), 0, 1}, // QuadTimer3_0 19 // AD_B1_00
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{1, M(4, 0), 1, 1}, // FlexPWM4_0_A 22 // AD_B1_08
|
||||||
|
{1, M(4, 1), 1, 1}, // FlexPWM4_1_A 23 // AD_B1_09
|
||||||
|
{1, M(1, 2), 0, 4}, // FlexPWM1_2_X 24 // AD_B0_12
|
||||||
|
{1, M(1, 3), 0, 4}, // FlexPWM1_3_X 25 // AD_B0_13
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{1, M(3, 1), 2, 1}, // FlexPWM3_1_B 28 // EMC_32
|
||||||
|
{1, M(3, 1), 1, 1}, // FlexPWM3_1_A 29 // EMC_31
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{1, M(2, 0), 2, 1}, // FlexPWM2_0_B 33 // EMC_07
|
||||||
|
#ifdef ARDUINO_TEENSY40
|
||||||
|
{1, M(1, 1), 2, 1}, // FlexPWM1_1_B 34 // SD_B0_03
|
||||||
|
{1, M(1, 1), 1, 1}, // FlexPWM1_1_A 35 // SD_B0_02
|
||||||
|
{1, M(1, 0), 2, 1}, // FlexPWM1_0_B 36 // SD_B0_01
|
||||||
|
{1, M(1, 0), 1, 1}, // FlexPWM1_0_A 37 // SD_B0_00
|
||||||
|
{1, M(1, 2), 2, 1}, // FlexPWM1_2_B 38 // SD_B0_05
|
||||||
|
{1, M(1, 2), 1, 1}, // FlexPWM1_2_A 39 // SD_B0_04
|
||||||
|
#endif
|
||||||
|
#ifdef ARDUINO_TEENSY41
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{1, M(2, 3), 1, 6}, // FlexPWM2_3_A 36 // B1_00
|
||||||
|
{1, M(2, 3), 2, 6}, // FlexPWM2_3_B 37 // B1_01
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{0, M(1, 0), 0, 0},
|
||||||
|
{1, M(1, 1), 2, 1}, // FlexPWM1_1_B 42 // SD_B0_03
|
||||||
|
{1, M(1, 1), 1, 1}, // FlexPWM1_1_A 43 // SD_B0_02
|
||||||
|
{1, M(1, 0), 2, 1}, // FlexPWM1_0_B 44 // SD_B0_01
|
||||||
|
{1, M(1, 0), 1, 1}, // FlexPWM1_0_A 45 // SD_B0_00
|
||||||
|
{1, M(1, 2), 2, 1}, // FlexPWM1_2_B 46 // SD_B0_05
|
||||||
|
{1, M(1, 2), 1, 1}, // FlexPWM1_2_A 47 // SD_B0_04
|
||||||
|
{0, M(1, 0), 0, 0}, // duplicate FlexPWM1_0_B
|
||||||
|
{0, M(1, 0), 0, 0}, // duplicate FlexPWM1_2_A
|
||||||
|
{0, M(1, 0), 0, 0}, // duplicate FlexPWM1_2_B
|
||||||
|
{1, M(3, 3), 2, 1}, // FlexPWM3_3_B 51 // EMC_22
|
||||||
|
{0, M(1, 0), 0, 0}, // duplicate FlexPWM1_1_B
|
||||||
|
{0, M(1, 0), 0, 0}, // duplicate FlexPWM1_1_A
|
||||||
|
{1, M(3, 0), 1, 1}, // FlexPWM3_0_A 53 // EMC_29
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
void HAL_print_analog_pin(char buffer[], int8_t pin) {
|
||||||
|
if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
|
||||||
|
else if (pin <= 41) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_analog_pin_state(char buffer[], int8_t pin) {
|
||||||
|
if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
|
||||||
|
else if (pin <= 41) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM: %4d"), V); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a pin's PWM status.
|
||||||
|
* Return true if it's currently a PWM pin.
|
||||||
|
*/
|
||||||
|
bool HAL_pwm_status(int8_t pin) {
|
||||||
|
char buffer[20]; // for the sprintf statements
|
||||||
|
const struct pwm_pin_info_struct *info;
|
||||||
|
|
||||||
|
if (pin >= CORE_NUM_DIGITAL) return 0;
|
||||||
|
info = pwm_pin_info + pin;
|
||||||
|
|
||||||
|
if (info->type == 0) return 0;
|
||||||
|
|
||||||
|
/* TODO decode pwm value from timers */
|
||||||
|
// for now just indicate if output is set as pwm
|
||||||
|
PWM_PRINT(*(portConfigRegister(pin)) == info->muxval);
|
||||||
|
return (*(portConfigRegister(pin)) == info->muxval);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pwm_details(uint8_t pin) { /* TODO */ }
|
27
Marlin/src/HAL/TEENSY40_41/spi_pins.h
Normal file
27
Marlin/src/HAL/TEENSY40_41/spi_pins.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define SCK_PIN 13
|
||||||
|
#define MISO_PIN 12
|
||||||
|
#define MOSI_PIN 11
|
||||||
|
#define SS_PIN 20 // SDSS // A.28, A.29, B.21, C.26, C.29
|
114
Marlin/src/HAL/TEENSY40_41/timers.cpp
Normal file
114
Marlin/src/HAL/TEENSY40_41/timers.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teensy4.0/4.1 (__IMXRT1062__)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0:
|
||||||
|
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
|
||||||
|
CCM_CCGR1 |= CCM_CCGR1_GPT1_BUS(CCM_CCGR_ON);
|
||||||
|
|
||||||
|
GPT1_CR = 0; // disable timer
|
||||||
|
GPT1_SR = 0x3F; // clear all prior status
|
||||||
|
GPT1_PR = GPT1_TIMER_PRESCALE - 1;
|
||||||
|
GPT1_CR |= GPT_CR_CLKSRC(1); //clock selection #1 (peripheral clock = 150 MHz)
|
||||||
|
GPT1_CR |= GPT_CR_ENMOD; //reset count to zero before enabling
|
||||||
|
GPT1_CR |= GPT_CR_OM1(1); // toggle mode
|
||||||
|
GPT1_OCR1 = (GPT1_TIMER_RATE / frequency) -1; // Initial compare value
|
||||||
|
GPT1_IR = GPT_IR_OF1IE; // Compare3 value
|
||||||
|
GPT1_CR |= GPT_CR_EN; //enable GPT2 counting at 150 MHz
|
||||||
|
|
||||||
|
OUT_WRITE(15, HIGH);
|
||||||
|
attachInterruptVector(IRQ_GPT1, &stepTC_Handler);
|
||||||
|
NVIC_SET_PRIORITY(IRQ_GPT1, 16);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
|
||||||
|
CCM_CCGR0 |= CCM_CCGR0_GPT2_BUS(CCM_CCGR_ON);
|
||||||
|
|
||||||
|
GPT2_CR = 0; // disable timer
|
||||||
|
GPT2_SR = 0x3F; // clear all prior status
|
||||||
|
GPT2_PR = GPT2_TIMER_PRESCALE - 1;
|
||||||
|
GPT2_CR |= GPT_CR_CLKSRC(1); //clock selection #1 (peripheral clock = 150 MHz)
|
||||||
|
GPT2_CR |= GPT_CR_ENMOD; //reset count to zero before enabling
|
||||||
|
GPT2_CR |= GPT_CR_OM1(1); // toggle mode
|
||||||
|
GPT2_OCR1 = (GPT2_TIMER_RATE / frequency) -1; // Initial compare value
|
||||||
|
GPT2_IR = GPT_IR_OF1IE; // Compare3 value
|
||||||
|
GPT2_CR |= GPT_CR_EN; //enable GPT2 counting at 150 MHz
|
||||||
|
|
||||||
|
OUT_WRITE(14, HIGH);
|
||||||
|
attachInterruptVector(IRQ_GPT2, &tempTC_Handler);
|
||||||
|
NVIC_SET_PRIORITY(IRQ_GPT2, 32);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0:
|
||||||
|
NVIC_ENABLE_IRQ(IRQ_GPT1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
NVIC_ENABLE_IRQ(IRQ_GPT2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
|
||||||
|
case 1: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||||
|
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
|
||||||
|
asm volatile("dsb");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0: return (NVIC_IS_ENABLED(IRQ_GPT1));
|
||||||
|
case 1: return (NVIC_IS_ENABLED(IRQ_GPT2));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0:
|
||||||
|
GPT1_SR = GPT_IR_OF1IE; // clear OF3 bit
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
GPT2_SR = GPT_IR_OF1IE; // clear OF3 bit
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
asm volatile("dsb");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __IMXRT1062__
|
120
Marlin/src/HAL/TEENSY40_41/timers.h
Normal file
120
Marlin/src/HAL/TEENSY40_41/timers.h
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
|
||||||
|
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: HAL for
|
||||||
|
* Teensy4.0/4.1 (__IMXRT1062__)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// ------------------------
|
||||||
|
// Defines
|
||||||
|
// ------------------------
|
||||||
|
|
||||||
|
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||||
|
|
||||||
|
typedef uint32_t hal_timer_t;
|
||||||
|
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFE
|
||||||
|
|
||||||
|
#define GPT_TIMER_RATE F_BUS_ACTUAL // 150MHz
|
||||||
|
|
||||||
|
#define GPT1_TIMER_PRESCALE 2
|
||||||
|
#define GPT2_TIMER_PRESCALE 10
|
||||||
|
|
||||||
|
#define GPT1_TIMER_RATE (GPT_TIMER_RATE / GPT1_TIMER_PRESCALE) // 75MHz
|
||||||
|
#define GPT2_TIMER_RATE (GPT_TIMER_RATE / GPT2_TIMER_PRESCALE) // 15MHz
|
||||||
|
|
||||||
|
#ifndef STEP_TIMER_NUM
|
||||||
|
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
|
||||||
|
#endif
|
||||||
|
#ifndef PULSE_TIMER_NUM
|
||||||
|
#define PULSE_TIMER_NUM STEP_TIMER_NUM
|
||||||
|
#endif
|
||||||
|
#ifndef TEMP_TIMER_NUM
|
||||||
|
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TEMP_TIMER_RATE 1000000
|
||||||
|
#define TEMP_TIMER_FREQUENCY 1000
|
||||||
|
|
||||||
|
#define STEPPER_TIMER_RATE GPT1_TIMER_RATE
|
||||||
|
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000)
|
||||||
|
#define STEPPER_TIMER_PRESCALE ((GPT_TIMER_RATE / 1000000) / STEPPER_TIMER_TICKS_PER_US)
|
||||||
|
|
||||||
|
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
|
||||||
|
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
|
||||||
|
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
|
||||||
|
|
||||||
|
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
|
||||||
|
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
|
||||||
|
#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
|
||||||
|
|
||||||
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
|
||||||
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
|
||||||
|
|
||||||
|
#ifndef HAL_STEP_TIMER_ISR
|
||||||
|
#define HAL_STEP_TIMER_ISR() extern "C" void stepTC_Handler() // GPT1_Handler()
|
||||||
|
#endif
|
||||||
|
#ifndef HAL_TEMP_TIMER_ISR
|
||||||
|
#define HAL_TEMP_TIMER_ISR() extern "C" void tempTC_Handler() // GPT2_Handler()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern "C" void stepTC_Handler();
|
||||||
|
extern "C" void tempTC_Handler();
|
||||||
|
|
||||||
|
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||||
|
|
||||||
|
FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0:
|
||||||
|
GPT1_OCR1 = compare - 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
GPT2_OCR1 = compare - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0: return GPT1_OCR1;
|
||||||
|
case 1: return GPT2_OCR1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
|
||||||
|
switch (timer_num) {
|
||||||
|
case 0: return GPT1_CNT;
|
||||||
|
case 1: return GPT2_CNT;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||||
|
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||||
|
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||||
|
|
||||||
|
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||||
|
//void HAL_timer_isr_epilogue(const uint8_t timer_num) {}
|
||||||
|
#define HAL_timer_isr_epilogue(TIMER_NUM)
|
52
Marlin/src/HAL/TEENSY40_41/watchdog.cpp
Normal file
52
Marlin/src/HAL/TEENSY40_41/watchdog.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifdef __IMXRT1062__
|
||||||
|
|
||||||
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
#if ENABLED(USE_WATCHDOG)
|
||||||
|
|
||||||
|
#include "watchdog.h"
|
||||||
|
|
||||||
|
// 4 seconds timeout
|
||||||
|
#define WDTO 4 //seconds
|
||||||
|
|
||||||
|
uint8_t timeoutval = (WDTO - 0.5f) / 0.5f;
|
||||||
|
|
||||||
|
void watchdog_init() {
|
||||||
|
|
||||||
|
CCM_CCGR3 |= CCM_CCGR3_WDOG1(3); // enable WDOG1 clocks
|
||||||
|
WDOG1_WMCR = 0; // disable power down PDE
|
||||||
|
WDOG1_WCR |= WDOG_WCR_SRS | WDOG_WCR_WT(timeoutval);
|
||||||
|
WDOG1_WCR |= WDOG_WCR_WDE | WDOG_WCR_WDT | WDOG_WCR_SRE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_watchdog_refresh() {
|
||||||
|
// Watchdog refresh sequence
|
||||||
|
WDOG1_WSR = 0x5555;
|
||||||
|
WDOG1_WSR = 0xAAAA;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_WATCHDOG
|
||||||
|
|
||||||
|
#endif // __IMXRT1062__
|
30
Marlin/src/HAL/TEENSY40_41/watchdog.h
Normal file
30
Marlin/src/HAL/TEENSY40_41/watchdog.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* Based on Sprinter and grbl.
|
||||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watchdog for Teensy4.0/4.1 (__IMXRT1062__)
|
||||||
|
*/
|
||||||
|
|
||||||
|
void watchdog_init();
|
||||||
|
|
||||||
|
void HAL_watchdog_refresh();
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user