Expand serial support in DUE/AVR hals exploiting the templated MarlinSerial classes (#11988)
This commit is contained in:
committed by
Scott Lahteine
parent
f6f2246f59
commit
d6955f25b2
@ -79,16 +79,32 @@ typedef int8_t pin_t;
|
||||
|
||||
//extern uint8_t MCUSR;
|
||||
|
||||
#define NUM_SERIAL 1
|
||||
|
||||
// Serial ports
|
||||
#ifdef USBCON
|
||||
#if ENABLED(BLUETOOTH)
|
||||
#define MYSERIAL0 bluetoothSerial
|
||||
#else
|
||||
#define MYSERIAL0 Serial
|
||||
#endif
|
||||
#define NUM_SERIAL 1
|
||||
#else
|
||||
#define MYSERIAL0 customizedSerial
|
||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||
#error "SERIAL_PORT must be from -1 to 3"
|
||||
#endif
|
||||
|
||||
#define MYSERIAL0 customizedSerial1
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
||||
#error "SERIAL_PORT_2 must be from -1 to 3"
|
||||
#elif SERIAL_PORT_2 == SERIAL_PORT
|
||||
#error "SERIAL_PORT_2 must be different than SERIAL_PORT"
|
||||
#endif
|
||||
#define NUM_SERIAL 2
|
||||
#define MYSERIAL1 customizedSerial2
|
||||
#else
|
||||
#define NUM_SERIAL 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -705,18 +705,37 @@
|
||||
|
||||
// Hookup ISR handlers
|
||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg>::store_rxd_char();
|
||||
MarlinSerial<MarlinSerialCfg1>::store_rxd_char();
|
||||
}
|
||||
|
||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_UDRE_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg>::_tx_udr_empty_irq();
|
||||
MarlinSerial<MarlinSerialCfg1>::_tx_udr_empty_irq();
|
||||
}
|
||||
|
||||
// Preinstantiate
|
||||
template class MarlinSerial<MarlinSerialCfg>;
|
||||
template class MarlinSerial<MarlinSerialCfg1>;
|
||||
|
||||
// Instantiate
|
||||
MarlinSerial<MarlinSerialCfg> customizedSerial;
|
||||
MarlinSerial<MarlinSerialCfg1> customizedSerial1;
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
|
||||
// Hookup ISR handlers
|
||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_RX_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg2>::store_rxd_char();
|
||||
}
|
||||
|
||||
ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_UDRE_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg2>::_tx_udr_empty_irq();
|
||||
}
|
||||
|
||||
// Preinstantiate
|
||||
template class MarlinSerial<MarlinSerialCfg2>;
|
||||
|
||||
// Instantiate
|
||||
MarlinSerial<MarlinSerialCfg2> customizedSerial2;
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
||||
|
||||
|
@ -256,7 +256,7 @@
|
||||
};
|
||||
|
||||
// Serial port configuration
|
||||
struct MarlinSerialCfg {
|
||||
struct MarlinSerialCfg1 {
|
||||
static constexpr int PORT = SERIAL_PORT;
|
||||
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
|
||||
@ -268,7 +268,27 @@
|
||||
static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
|
||||
};
|
||||
|
||||
extern MarlinSerial<MarlinSerialCfg> customizedSerial;
|
||||
extern MarlinSerial<MarlinSerialCfg1> customizedSerial1;
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
|
||||
// Serial port configuration
|
||||
struct MarlinSerialCfg2 {
|
||||
static constexpr int PORT = SERIAL_PORT_2;
|
||||
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
|
||||
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
|
||||
static constexpr bool XONOFF = bSERIAL_XON_XOFF;
|
||||
static constexpr bool EMERGENCYPARSER = bEMERGENCY_PARSER;
|
||||
static constexpr bool DROPPED_RX = bSERIAL_STATS_DROPPED_RX;
|
||||
static constexpr bool RX_OVERRUNS = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
|
||||
static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
|
||||
static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
|
||||
};
|
||||
|
||||
extern MarlinSerial<MarlinSerialCfg2> customizedSerial2;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // !USBCON
|
||||
|
||||
|
Reference in New Issue
Block a user