+/*#*
+ *#* $Log$
+ *#* Revision 1.34 2006/11/23 13:19:02 batt
+ *#* Add support for ATmega1281.
+ *#*
+ *#* Revision 1.33 2006/09/13 18:21:24 bernie
+ *#* Add configurable SPI pin mapping.
+ *#*
+ *#* Revision 1.32 2006/07/19 12:56:26 bernie
+ *#* Convert to new Doxygen style.
+ *#*
+ *#* Revision 1.31 2006/05/18 00:37:29 bernie
+ *#* Use hw_ser.h instead of ubiquitous hw.h.
+ *#*
+ *#* Revision 1.30 2006/02/17 22:23:06 bernie
+ *#* Update POSIX serial emulator.
+ *#*
+ *#* Revision 1.29 2005/11/27 23:31:48 bernie
+ *#* Support avr-libc 1.4.
+ *#*
+ *#* Revision 1.28 2005/11/04 16:20:02 bernie
+ *#* Fix reference to README.devlib in header.
+ *#*
+ *#* Revision 1.27 2005/07/03 15:19:31 bernie
+ *#* Doxygen fix.
+ *#*
+ *#* Revision 1.26 2005/04/11 19:10:27 bernie
+ *#* Include top-level headers from cfg/ subdir.
+ *#*
+ *#* Revision 1.25 2005/01/25 08:37:26 bernie
+ *#* CONFIG_SER_HWHANDSHAKE fixes.
+ *#*
+ *#* Revision 1.24 2005/01/14 00:49:16 aleph
+ *#* Rename callbacks; SerialHardwareVT.txSending: New callback; Add SPI_BUS macros.
+ *#*
+ *#* Revision 1.23 2005/01/11 18:09:07 aleph
+ *#* Add ATmega8 SPI port definitions; Fix transmit complete IRQ bug; add strobe macros to uart1 and spi
+ *#*
+ *#* Revision 1.22 2004/12/31 17:47:45 bernie
+ *#* Rename UNUSED() to UNUSED_ARG().
+ *#*
+ *#* Revision 1.21 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
+ *#* Revision 1.20 2004/12/13 11:51:43 bernie
+ *#* Fix a latent bug with reentrant serial IRQs.
+ *#*
+ *#* Revision 1.19 2004/12/13 11:51:08 bernie
+ *#* DISABLE_INTS/ENABLE_INTS: Convert to IRQ_DISABLE/IRQ_ENABLE.
+ *#*
+ *#* Revision 1.18 2004/12/08 08:03:48 bernie
+ *#* Doxygen fixes.
+ *#*
+ *#* Revision 1.17 2004/10/19 07:52:35 bernie
+ *#* Reset parity bits before overwriting them (Fixed by batt in project_ks).
+ *#*
+ *#* Revision 1.16 2004/10/03 18:45:48 bernie
+ *#* Convert to new-style config macros; Allow compiling with a C++ compiler (mostly).
+ *#*
+ *#* Revision 1.15 2004/09/14 21:05:36 bernie
+ *#* Use debug.h instead of kdebug.h; Use new AVR pin names; Spelling fixes.
+ *#*
+ *#* Revision 1.14 2004/09/06 21:50:00 bernie
+ *#* Spelling fixes.
+ *#*
+ *#* Revision 1.13 2004/09/06 21:40:50 bernie
+ *#* Move buffer handling in chip-specific driver.
+ *#*
+ *#* Revision 1.12 2004/08/29 22:06:10 bernie
+ *#* Fix a bug in the (unused) RTS/CTS code; Clarify documentation.
+ *#*
+ *#* Revision 1.10 2004/08/10 06:30:41 bernie
+ *#* Major redesign of serial bus policy handling.
+ *#*
+ *#* Revision 1.9 2004/08/02 20:20:29 aleph
+ *#* Merge from project_ks
+ *#*
+ *#* Revision 1.8 2004/07/29 22:57:09 bernie
+ *#* Several tweaks to reduce code size on ATmega8.
+ *#*
+ *#* Revision 1.7 2004/07/18 21:54:23 bernie
+ *#* Add ATmega8 support.
+ *#*
+ *#* Revision 1.5 2004/06/27 15:25:40 aleph
+ *#* Add missing callbacks for SPI;
+ *#* Change UNUSED() macro to new version with two args;
+ *#* Use TX line filling only on the correct KBUS serial port;
+ *#* Fix nasty IRQ disabling bug in recv complete hander for port 1.
+ *#*
+ *#* Revision 1.4 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.3 2004/06/02 21:35:24 aleph
+ *#* Serial enhancements: interruptible receive handler and 8 bit serial status for AVR; remove volatile attribute to FIFOBuffer, useless for new fifobuf routens
+ *#*
+ *#* Revision 1.2 2004/05/23 18:21:53 bernie
+ *#* Trim CVS logs and cleanup header info.
+ *#*
+ *#*/
+
+#include "ser.h"
+#include "ser_p.h"
+
+#include <hw_ser.h> /* Required for bus macros overrides */
+#include <hw_cpu.h> /* CLOCK_FREQ */
+#include <appconfig.h>
+
+#include <cfg/debug.h>
+#include <drv/timer.h>
+#include <mware/fifobuf.h>
+
+#include <avr/io.h>
+#if defined(__AVR_LIBC_VERSION__) && (__AVR_LIBC_VERSION__ >= 10400UL)
+ #include <avr/interrupt.h>
+#else
+ #include <avr/signal.h>
+#endif
+
+
+#if !CONFIG_SER_HWHANDSHAKE
+ /**
+ * \name Hardware handshake (RTS/CTS).
+ * \{
+ */
+ #define RTS_ON do {} while (0)
+ #define RTS_OFF do {} while (0)
+ #define IS_CTS_ON true
+ #define EIMSKF_CTS 0 /**< Dummy value, must be overridden */
+ /*\}*/
+#endif
+
+#if CPU_AVR_ATMEGA1281
+ #define BIT_RXCIE0 RXCIE0
+ #define BIT_RXEN0 RXEN0
+ #define BIT_TXEN0 TXEN0
+ #define BIT_UDRIE0 UDRIE0
+
+ #define BIT_RXCIE1 RXCIE1
+ #define BIT_RXEN1 RXEN1
+ #define BIT_TXEN1 TXEN1
+ #define BIT_UDRIE1 UDRIE1
+#else
+ #define BIT_RXCIE0 RXCIE
+ #define BIT_RXEN0 RXEN
+ #define BIT_TXEN0 TXEN
+ #define BIT_UDRIE0 UDRIE
+
+ #define BIT_RXCIE1 RXCIE
+ #define BIT_RXEN1 RXEN
+ #define BIT_TXEN1 TXEN
+ #define BIT_UDRIE1 UDRIE
+#endif
+
+
+/**
+ * \name Overridable serial bus hooks