Fix and improve STM32F1 serial (#19464)
This commit is contained in:
@ -96,19 +96,14 @@ typedef int8_t pin_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
|
||||
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
||||
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
|
||||
#endif
|
||||
#define DGUS_SERIAL internalDgusSerial
|
||||
#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_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."
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#if HAS_DGUS_LCD
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
|
||||
#endif
|
||||
#define ANYCUBIC_LCD_SERIAL anycubicLcdSerial
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -217,10 +217,12 @@
|
||||
static ring_buffer_pos_t available();
|
||||
static void write(const uint8_t c);
|
||||
static void flushTX();
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#if HAS_DGUS_LCD
|
||||
static ring_buffer_pos_t get_tx_buffer_free();
|
||||
#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 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; }
|
||||
@ -278,55 +280,50 @@
|
||||
|
||||
#endif // !USBCON
|
||||
|
||||
#ifdef INTERNAL_SERIAL_PORT
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
struct MMU2SerialCfg {
|
||||
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 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_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
|
||||
|
||||
#ifdef DGUS_SERIAL_PORT
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
|
||||
template <uint8_t serial>
|
||||
struct MarlinInternalSerialCfg {
|
||||
static constexpr int PORT = serial;
|
||||
static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||
static constexpr bool XONOFF = false;
|
||||
static constexpr bool EMERGENCYPARSER = false;
|
||||
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;
|
||||
struct LCDSerialCfg {
|
||||
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 TX_SIZE = DGUS_TX_BUFFER_SIZE;
|
||||
static constexpr bool RX_OVERRUNS = ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
|
||||
static constexpr unsigned int RX_SIZE = 64;
|
||||
static constexpr unsigned int TX_SIZE = 128;
|
||||
static constexpr bool RX_OVERRUNS = false;
|
||||
#else
|
||||
static constexpr unsigned int RX_SIZE = 64;
|
||||
static constexpr unsigned int TX_SIZE = 128;
|
||||
static constexpr bool RX_OVERRUNS = false
|
||||
#endif
|
||||
};
|
||||
|
||||
extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
|
||||
#endif
|
||||
extern MarlinSerial<LCDSerialCfg<LCD_SERIAL_PORT>> lcdSerial;
|
||||
|
||||
#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 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_FRAMING_ERRORS = false;
|
||||
static constexpr bool MAX_RX_QUEUED = false;
|
||||
};
|
||||
|
||||
extern MarlinSerial<AnycubicLcdSerialCfg<ANYCUBIC_LCD_SERIAL_PORT>> anycubicLcdSerial;
|
||||
#endif
|
||||
|
||||
// Use the UART for Bluetooth in AT90USB configurations
|
||||
|
Reference in New Issue
Block a user