X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=cpu%2Favr%2Fdrv%2Fser_avr.c;h=e9e1f5ec186907eb8033ed140c35fcb710eacfdd;hb=1fc31f45bcec8bc23a5924ae5b288439abca8ded;hp=7b55318005bac0877c4e3488984fc3ac147edf27;hpb=9c6545aacf8bb77445e7c19e41117d2318d752cc;p=bertos.git diff --git a/cpu/avr/drv/ser_avr.c b/cpu/avr/drv/ser_avr.c index 7b553180..e9e1f5ec 100644 --- a/cpu/avr/drv/ser_avr.c +++ b/cpu/avr/drv/ser_avr.c @@ -61,113 +61,14 @@ * \author Stefano Fedrigo */ -/*#* - *#* $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 +#include #include /* Required for bus macros overrides */ #include /* CLOCK_FREQ */ #include +#include /* DIV_ROUND */ #include #include #include @@ -509,7 +410,7 @@ static void uart0_enabletxirq(struct SerialHardware *_hw) static void uart0_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate) { /* Compute baud-rate period */ - uint16_t period = (((CLOCK_FREQ / 16UL) + (rate / 2)) / rate) - 1; + uint16_t period = DIV_ROUND(CLOCK_FREQ / 16UL, rate) - 1; #if !CPU_AVR_ATMEGA103 UBRR0H = (period) >> 8; @@ -562,7 +463,7 @@ static void uart1_enabletxirq(struct SerialHardware *_hw) static void uart1_setbaudrate(UNUSED_ARG(struct SerialHardware *, _hw), unsigned long rate) { /* Compute baud-rate period */ - uint16_t period = (((CLOCK_FREQ / 16UL) + (rate / 2)) / rate) - 1; + uint16_t period = DIV_ROUND(CLOCK_FREQ / 16UL, rate) - 1; UBRR1H = (period) >> 8; UBRR1L = (period);