X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fkdebug_sam3.c;h=45b2cf59598c1d077b11af362d392b9200c9a1b2;hb=f1fab319eb3fe91c157b3a9564841aef62a03554;hp=80e5501f2f9e1aeb4748d55ba985c473c2990317;hpb=e444d916197e4345dd2bbd85800d8544c2699096;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/kdebug_sam3.c b/bertos/cpu/cortex-m3/drv/kdebug_sam3.c index 80e5501f..45b2cf59 100644 --- a/bertos/cpu/cortex-m3/drv/kdebug_sam3.c +++ b/bertos/cpu/cortex-m3/drv/kdebug_sam3.c @@ -30,7 +30,7 @@ * * --> * - * \brief AT91SAM3 debug support (implementation). + * \brief SAM3 debug support (implementation). * * \author Stefano Fedrigo */ @@ -38,19 +38,23 @@ #include #include /* for BV() */ +#include + #include -#if CONFIG_KDEBUG_PORT == 0 +#if (CONFIG_KDEBUG_PORT == 0) #define UART_BASE UART0_BASE - #define UART_INT INT_UART0 - #define UART_PIO_BASE PIOA_BASE - #define UART_PINS (BV(RXD0) | BV(TXD0)) -#elif (CONFIG_KDEBUG_PORT == 1) && !defined(CPU_CM3_AT91SAM3U) + #define UART_ID UART0_ID + #define UART_PIO_BASE UART0_PORT + #define UART_PERIPH UART0_PERIPH + #define UART_PINS (BV(URXD0) | BV(UTXD0)) +#elif (CONFIG_KDEBUG_PORT == 1) && UART_PORTS > 1 #define UART_BASE UART1_BASE - #define UART_INT INT_UART1 - #define UART_PIO_BASE PIOB_BASE - #define UART_PINS (BV(RXD1) | BV(TXD1)) + #define UART_ID UART1_ID + #define UART_PIO_BASE UART1_PORT + #define UART_PERIPH UART1_PERIPH + #define UART_PINS (BV(URXD1) | BV(UTXD1)) #else #error "UART port not supported in this board" #endif @@ -72,13 +76,15 @@ typedef uint32_t kdbg_irqsave_t; INLINE void kdbg_hw_init(void) { - /* Disable PIO mode and set appropriate UART pins peripheral mode */ + /* + * Disable PIO mode and set appropriate UART pins peripheral mode. + * SAM3X,A,N,S,U: all of them has all UARTs on peripheral A. + */ HWREG(UART_PIO_BASE + PIO_PDR_OFF) = UART_PINS; - HWREG(UART_PIO_BASE + PIO_ABCDSR1_OFF) &= ~UART_PINS; - HWREG(UART_PIO_BASE + PIO_ABCDSR2_OFF) &= ~UART_PINS; + PIO_PERIPH_SEL(UART_PIO_BASE, UART_PINS, UART_PERIPH); /* Enable the peripheral clock */ - PMC_PCER |= BV(UART_INT); + pmc_periphEnable(UART_ID); /* Reset and disable receiver & transmitter */ HWREG(UART_BASE + UART_CR_OFF) = BV(UART_CR_RSTRX) | BV(UART_CR_RSTTX) | BV(UART_CR_RXDIS) | BV(UART_CR_TXDIS);