Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more STM32F1 Serial hangs due to overflows #19464

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3e3e187
Update Malyan LCD to use MSerial on STM32F1, and try to prevent use o…
sjasonsmith Sep 21, 2020
6a718b2
Add Configuration.h option.
sjasonsmith Sep 21, 2020
d59c3d2
Allow compiling with STM32 HAL (for Malyan M200/M300)
sjasonsmith Sep 22, 2020
2b824e4
Fix minor issues impacting CI
sjasonsmith Sep 22, 2020
3432150
Macros for other serial port defines
thinkyhead Sep 23, 2020
60a7c21
tweak option name
thinkyhead Sep 23, 2020
d7986fa
Misc fixes, adjustments
thinkyhead Sep 23, 2020
9d81ee6
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19464
thinkyhead Sep 23, 2020
62b4062
Tweak ANY_RX
thinkyhead Sep 23, 2020
997cad7
Update MarlinSerial.h
thinkyhead Sep 23, 2020
4b0aa06
Fix, consolidate serial sanity-checking
thinkyhead Sep 23, 2020
6a6432c
Merge branch 'PR/18358_F1_Serial_Ints' of https://github.com/sjasonsm…
thinkyhead Sep 23, 2020
678799c
Macro patch
thinkyhead Sep 23, 2020
19abe24
prep for redo
thinkyhead Sep 23, 2020
5cc87f9
Define NUM_SERIAL once
thinkyhead Sep 23, 2020
2d4d582
keep feet on ground
thinkyhead Sep 23, 2020
f16388b
etc
thinkyhead Sep 24, 2020
804d1b1
Update Configuration.h
thinkyhead Sep 24, 2020
d6035bc
HAL and serial cleanup
thinkyhead Sep 24, 2020
98a225d
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19464
thinkyhead Sep 24, 2020
db35a68
Merge branch 'bf2_lcd_serial_fixups_19464' into pr/19464
thinkyhead Sep 24, 2020
3732dd8
typo
thinkyhead Sep 24, 2020
d974f7a
fix test
thinkyhead Sep 24, 2020
b253be5
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19464
thinkyhead Sep 24, 2020
e24ee2e
Consolidate LCD_SERIAL defines
thinkyhead Sep 24, 2020
a2641dc
lcd baudrate
thinkyhead Sep 24, 2020
69c6c3d
Serial fixes
thinkyhead Sep 24, 2020
a598fc7
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/19464
thinkyhead Sep 24, 2020
824d31a
better
thinkyhead Sep 24, 2020
ab550c8
Shift MarlinSerial left
thinkyhead Sep 24, 2020
1bb005d
Ok to keep JTAG off?
thinkyhead Sep 24, 2020
d3d5f91
Remove duplicate LCD_SERIAL check
sjasonsmith Sep 24, 2020
f49dc6b
Add MSerial::emergency_parser_enabled
thinkyhead Sep 25, 2020
9428396
Add a bunch of logic
thinkyhead Sep 25, 2020
d98d7d8
Apply to other HALs
thinkyhead Sep 25, 2020
f8d538d
Fix ep-enabled
thinkyhead Sep 25, 2020
9bfdbee
Evaluate macro arg
thinkyhead Sep 25, 2020
a830dbd
undo 1
thinkyhead Sep 25, 2020
4c54163
Revert serial logic
thinkyhead Sep 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,10 @@
// Touch-screen LCD for Malyan M200/M300 printers
//
//#define MALYAN_LCD
#if ENABLED(MALYAN_LCD)
// This will be 1 on a Malyan M200, but may differ on other boards.
#define MALYAN_LCD_SERIAL_PORT 1
#endif
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

//
// Touch UI for FTDI EVE (FT800/FT810) displays
Expand Down
81 changes: 33 additions & 48 deletions Marlin/src/HAL/STM32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,82 +43,67 @@
// ------------------------
// Defines
// ------------------------
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

#if SERIAL_PORT == 0
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#if SERIAL_PORT == -1
#define MYSERIAL0 SerialUSB
#elif SERIAL_PORT == 1
#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
#elif SERIAL_PORT == 6
#define MYSERIAL0 MSerial6
#elif WITHIN(SERIAL_PORT, 1, 6)
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
#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

#ifdef SERIAL_PORT_2
#define NUM_SERIAL 2
#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
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 SerialUSB
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 MSerial1
#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
#elif WITHIN(SERIAL_PORT_2, 1, 6)
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
#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
#else
#define NUM_SERIAL 1
#endif


#if HAS_DGUS_LCD
#if DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL 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
#elif WITHIN(DGUS_SERIAL_PORT, 1, 6)
#define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT)
#else
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#error "DGUS_SERIAL must be -1 or from 1 to 6. Please update your configuration."
#endif

#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
#endif

#ifdef MALYAN_LCD
#define _FRAMEWORK_SERIAL(X) Serial##X
#define FRAMEWORK_SERIAL(X) _FRAMEWORK_SERIAL(X)

#ifndef MALYAN_LCD_SERIAL_PORT
#error "MALYAN_LCD requires MALYAN_LCD_SERIAL_PORT to be defined in Configuration.h"
#elif MALYAN_LCD_SERIAL_PORT == SERIAL_PORT
#error "MALYAN_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && MALYAN_LCD_SERIAL_PORT == SERIAL_PORT_2
#error "MALYAN_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif defined(DGUS_SERIAL) && MALYAN_LCD_SERIAL_PORT == DGUS_SERIAL_PORT
#error "MALYAN_LCD_SERIAL_PORT must be different than DGUS_SERIAL_PORT. Please update your configuration."
#elif WITHIN(MALYAN_LCD_SERIAL_PORT, 1, 6)
#define MALYAN_LCD_SERIAL FRAMEWORK_SERIAL(MALYAN_LCD_SERIAL_PORT)
#else
#error "MALYAN_LCD_SERIAL_PORT must be from 1 to 6. Please update your configuration."
#endif
#endif

/**
* TODO: review this to return 1 for pins that are not analog input
Expand Down
86 changes: 44 additions & 42 deletions Marlin/src/HAL/STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,73 +68,75 @@
#endif
#endif

#if SERIAL_PORT == 0
#error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif SERIAL_PORT == -1
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)

#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#define NUM_UARTS 5
#else
#define NUM_UARTS 3
#endif

#if SERIAL_PORT == -1
#define MYSERIAL0 UsbSerial
#elif SERIAL_PORT == 1
#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
#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
#define MYSERIAL0 MSERIAL(SERIAL_PORT)
#elif defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
#else
#error "SERIAL_PORT must be from -1 to 5. Please update your configuration."
#error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
#endif

#ifdef SERIAL_PORT_2
#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
#if SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL1 UsbSerial
#elif SERIAL_PORT_2 == 1
#define MYSERIAL1 MSerial1
#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 WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
#define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
#elif defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
#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
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 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 WITHIN(DGUS_SERIAL_PORT, 1, NUM_UARTS)
#define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT)
#elif defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#error "DGUS_SERIAL must be -1 or from 1 to 5. Please update your configuration."
#else
#error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration."
#error "DGUS_SERIAL must be -1 or from 1 to 3. Please update your configuration."
#endif
#endif

#ifdef MALYAN_LCD
#ifndef MALYAN_LCD_SERIAL_PORT
#error "MALYAN_LCD requires MALYAN_LCD_SERIAL_PORT to be defined in Configuration.h"
#elif MALYAN_LCD_SERIAL_PORT == SERIAL_PORT
#error "MALYAN_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && MALYAN_LCD_SERIAL_PORT == SERIAL_PORT_2
#error "MALYAN_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif defined(DGUS_SERIAL) && MALYAN_LCD_SERIAL_PORT == DGUS_SERIAL_PORT
#error "MALYAN_LCD_SERIAL_PORT must be different than DGUS_SERIAL_PORT. Please update your configuration."
#elif WITHIN(MALYAN_LCD_SERIAL_PORT, 1, NUM_UARTS)
#define MALYAN_LCD_SERIAL MSERIAL(MALYAN_LCD_SERIAL_PORT)
#elif defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#error "MALYAN_LCD_SERIAL_PORT must be from 1 to 5. Please update your configuration."
#else
#error "MALYAN_LCD_SERIAL_PORT must be from 1 to 3. Please update your configuration."
#endif
#endif

// Set interrupt grouping for this MCU
void HAL_init();
Expand Down
Loading