Add support for at91sam7x.
[bertos.git] / cpu / arm / drv / kdebug_at91.c
index 7de1c6d939e10b7c5552a779506e00034e0fe970..64b3845f37ea3a07dafec6cf694a3abaf2646939 100644 (file)
@@ -37,7 +37,7 @@
  */
 
 #include "kdebug_at91.h"
-#include <cfg/macros.h> /* for BV() */
+#include <cfg/macros.h> /* for BV(), DIV_ROUND */
 #include <appconfig.h>
 #include <hw_cpu.h>     /* for CLOCK_FREQ */
 #include <hw_ser.h>     /* Required for bus macros overrides */
@@ -71,12 +71,12 @@ INLINE void kdbg_hw_init(void)
                /* Reset DBGU */
                DBGU_CR =  BV(US_RSTRX) | BV(US_RSTTX) | BV(US_RXDIS) | BV(US_TXDIS);
                /* Set baudrate */
-               DBGU_BRGR = (CLOCK_FREQ + (16 * CONFIG_KDEBUG_BAUDRATE) / 2) / (16 * CONFIG_KDEBUG_BAUDRATE);
+               DBGU_BRGR = DIV_ROUND(CLOCK_FREQ, 16 * CONFIG_KDEBUG_BAUDRATE);
                /* Set DBGU mode to 8 data bits, no parity and 1 stop bit. */
                DBGU_MR =  US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1;
                /* Enable DBGU transmitter. */
                DBGU_CR = BV(US_TXEN);
-               #if !CPU_ARM_AT91SAM7S256
+               #if !CPU_ARM_AT91SAM7S256 && !CPU_ARM_AT91SAM7X256
                        #warning Check Debug Unit AT91 pins on datasheet!
                #endif
                /* Disable PIO on DGBU tx pin. */