|
|
@ -24,7 +24,7 @@ |
|
|
|
#include "Marlin.h" |
|
|
|
|
|
|
|
#if !defined(SERIAL_PORT) |
|
|
|
#error SERIAL_PORT not set |
|
|
|
#define SERIAL_PORT 0 |
|
|
|
#endif |
|
|
|
|
|
|
|
// 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
|
|
|
|
// requires two levels of indirection to expand macro values properly)
|
|
|
|
#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 |
|
|
|
#else |
|
|
|
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix |
|
|
@ -43,21 +43,13 @@ |
|
|
|
|
|
|
|
// Registers used by MarlinSerial class (these are expanded
|
|
|
|
// depending on selected serial port
|
|
|
|
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRxA where x is the serial port number
|
|
|
|
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
|
|
|
|
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) |
|
|
|
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) |
|
|
|
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) |
|
|
|
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) |
|
|
|
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) |
|
|
|
#if SERIAL_PORT == 0 && !defined(UDR0) |
|
|
|
#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_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) |
|
|
|
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) |
|
|
|