Refactor BeRTOS to be in his own directory.
[bertos.git] / cpu / arm / drv / kdebug_at91.c
index 7de1c6d939e10b7c5552a779506e00034e0fe970..b7e24cd3cc38e7c836543f8aa637f33eaf3635b1 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,28 +71,21 @@ 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
-                       #warning Check Debug Unit AT91 pins on datasheet!
-               #endif
                /* Disable PIO on DGBU tx pin. */
-               PIOA_PDR = BV(10);
-               PIOA_ASR = BV(10);
+               PIOA_PDR = BV(DTXD);
+               PIOA_ASR = BV(DTXD);
                
                #if 0 /* Disable Rx for now */
                /* Enable DBGU receiver. */
                DBGU_CR = BV(US_RXEN);
-               #if !CPU_ARM_AT91SAM7S256
-                       #warning Check Debug Unit AT91 pins on datasheet!
-               #endif
                /* Disable PIO on DGBU rx pin. */
-               PIOA_PDR = BV(9);
-               PIOA_ASR = BV(9);
-
+               PIOA_PDR = BV(DRXD);
+               PIOA_ASR = BV(DRXD);
                #endif
        #else
                #error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU