Browse Source

Apply TMC UART to STM32, simplify

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
committed by Scott Lahteine
parent
commit
e817db62a4
  1. 2
      Marlin/src/HAL/DUE/MarlinSerial.cpp
  2. 39
      Marlin/src/HAL/STM32/MarlinSerial.cpp
  3. 8
      Marlin/src/inc/Conditionals_post.h

2
Marlin/src/HAL/DUE/MarlinSerial.cpp

@ -476,7 +476,7 @@ void MarlinSerial<Cfg>::flushTX() {
// If not using the USB port as serial port // If not using the USB port as serial port
#if SERIAL_PORT >= 0 #if defined(SERIAL_PORT) && SERIAL_PORT >= 0
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >; template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER); MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
#endif #endif

39
Marlin/src/HAL/STM32/MarlinSerial.cpp

@ -37,19 +37,38 @@
MSerialT MSerial ## ser_num (true, USART ## ser_num, &_rx_complete_irq_ ## ser_num); \ MSerialT MSerial ## ser_num (true, USART ## ser_num, &_rx_complete_irq_ ## ser_num); \
void _rx_complete_irq_ ## ser_num (serial_t * obj) { MSerial ## ser_num ._rx_complete_irq(obj); } void _rx_complete_irq_ ## ser_num (serial_t * obj) { MSerial ## ser_num ._rx_complete_irq(obj); }
#define DECLARE_SERIAL_PORT_EXP(ser_num) DECLARE_SERIAL_PORT(ser_num) #if USING_HW_SERIAL1
DECLARE_SERIAL_PORT(1)
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 #endif
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT) #if USING_HW_SERIAL2
DECLARE_SERIAL_PORT(2)
#endif
#if USING_HW_SERIAL3
DECLARE_SERIAL_PORT(3)
#endif
#if USING_HW_SERIAL4
DECLARE_SERIAL_PORT(4)
#endif
#if USING_HW_SERIAL5
DECLARE_SERIAL_PORT(5)
#endif
#if USING_HW_SERIAL6
DECLARE_SERIAL_PORT(6)
#endif
#if USING_HW_SERIAL7
DECLARE_SERIAL_PORT(7)
#endif
#if USING_HW_SERIAL8
DECLARE_SERIAL_PORT(8)
#endif #endif
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 #if USING_HW_SERIAL9
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2) DECLARE_SERIAL_PORT(9)
#endif #endif
#if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0 #if USING_HW_SERIAL10
DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT) DECLARE_SERIAL_PORT(10)
#endif #endif
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0 #if USING_HW_SERIALLP1
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT) DECLARE_SERIAL_PORT(LP1)
#endif #endif
void MarlinSerial::begin(unsigned long baud, uint8_t config) { void MarlinSerial::begin(unsigned long baud, uint8_t config) {

8
Marlin/src/inc/Conditionals_post.h

@ -1842,13 +1842,6 @@
// Set USING_HW_SERIALn flags for used Serial Ports // Set USING_HW_SERIALn flags for used Serial Ports
// //
// ... HW_SerialX
#define _SERIAL_ID(P) _CAT(HW_,P)
// ... (HW_Serial1 == HW_SerialX || HW_Serial1 == HW_MSerialX)
#define _TMC_UART_IS(P,N) ( _SERIAL_ID(P##_HARDWARE_SERIAL) == _SERIAL_ID(Serial##N) || _SERIAL_ID(P) == _SERIAL_ID(MSerial##N) )
#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && _TMC_UART_IS(A, N))
// Flag the indexed hardware serial ports in use // Flag the indexed hardware serial ports in use
#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ #define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
|| (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \
@ -1856,6 +1849,7 @@
|| (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) ) || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) )
// Flag the named hardware serial ports in use // Flag the named hardware serial ports in use
#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N))
#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ #define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \
|| TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
|| TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \

Loading…
Cancel
Save