X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=cpu%2Farm%2Fdrv%2Fkdebug_at91.c;h=a5ec8343e7362a8fd30edd55bb516f4700f1ae41;hb=2d0bc916c5779e2f3dc9e4775e235e0c633817cc;hp=3526139992d71cd093b4b91da69cb700d45943e4;hpb=4be63e9bf292129a3d9771025528d254646180fe;p=bertos.git diff --git a/cpu/arm/drv/kdebug_at91.c b/cpu/arm/drv/kdebug_at91.c index 35261399..a5ec8343 100644 --- a/cpu/arm/drv/kdebug_at91.c +++ b/cpu/arm/drv/kdebug_at91.c @@ -37,8 +37,7 @@ */ #include "kdebug_at91.h" -#include -#include /* for BV() */ +#include /* for BV(), DIV_ROUND */ #include #include /* for CLOCK_FREQ */ #include /* Required for bus macros overrides */ @@ -72,29 +71,28 @@ 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); - /* Disable PIO on DGBU tx pin. */ - #if CPU_ARM_AT91SAM7S256 - PIOA_PDR = BV(10); - PIOA_ASR = BV(10); - #else + #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); #if 0 /* Disable Rx for now */ /* Enable DBGU receiver. */ DBGU_CR = BV(US_RXEN); - /* Disable PIO on DGBU rx pin. */ - #if CPU_ARM_AT91SAM7S256 - PIOA_PDR = BV(9); - PIOA_ASR = BV(9); - #else - #warning Check Debug pins on datasheet! + #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); + #endif #else #error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU