@ -24,7 +24,7 @@
# include "Marlin.h"
# include "Marlin.h"
# if !defined(SERIAL_PORT)
# if !defined(SERIAL_PORT)
# error SERIAL_PORT not set
# define SERIAL_PORT 0
# endif
# endif
// The presence of the UBRRH register is used to detect a UART.
// The presence of the UBRRH register is used to detect a UART.
@ -35,7 +35,7 @@
// 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_INTERNAL(registerbase,number,suffix)
# if SERIAL_PORT == 0 && !defined(UBRR0H)
# 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_INTERNAL(registerbase,number,suffix) registerbase##suffix
# else
# else
# define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
# define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
@ -43,21 +43,13 @@
// Registers used by MarlinSerial class (these are expanded
// Registers used by MarlinSerial class (these are expanded
// depending on selected serial port
// depending on selected serial port
# define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSR xA where x is the serial port number
# define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSR nA where n is the serial port number
# define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
# define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
# define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
# define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
# define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
# define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
# define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
# define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
# define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
# define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
# if SERIAL_PORT == 0 && !defined(UDR0)
# define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
# if defined(UDR)
# define M_UDRx UDR // atmega8, atmega32
# else
# error UDR not defined
# endif
# else
# define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
# endif
# define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
# define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
# define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
# define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
# define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
# define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)