Merge pull request #290 from buildrob/Marlin_v1

Clean up special serial port cases
This commit is contained in:
daid 2012-11-07 02:00:26 -08:00
commit faea7d72b8
2 changed files with 8 additions and 15 deletions

View File

@ -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,29 +35,21 @@
// 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
#else
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
#endif
// 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_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
#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,)
@ -189,4 +181,4 @@ class MarlinSerial //: public Stream
extern MarlinSerial MSerial;
#endif // ! teensylu
#endif
#endif

View File

@ -45,6 +45,7 @@ Features:
* Heater power reporting. Useful for PID monitoring.
* PID tuning
* CoreXY kinematics (www.corexy.com/theory.html)
* Configurable serial port to support connection of wireless adaptors.
The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.