From 55a397984bf28f7ad9cc804d8d1c7d1c68d32e8b Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 8 Feb 2008 17:25:29 +0000 Subject: [PATCH] Fix DM320 serial configuration problem git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@661 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/common/up_internal.h | 10 ++++----- arch/arm/src/dm320/dm320_serial.c | 2 +- arch/arm/src/dm320/dm320_uart.h | 34 +++++++++++++++++-------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h index 4d84f2cdd4..182e6058c8 100644 --- a/arch/arm/src/common/up_internal.h +++ b/arch/arm/src/common/up_internal.h @@ -49,11 +49,11 @@ * board bring-up and not part of normal platform configuration. */ -#undef CONFIG_SUPPRESS_INTERRUPTS /* Do not enable interrupts */ -#undef CONFIG_SUPPRESS_TIMER_INTS /* No timer */ -#undef CONFIG_SUPPRESS_SERIAL_INTS /* Console will poll */ -#define CONFIG_SUPPRESS_UART_CONFIG 1 /* Do not reconfig UART */ -#undef CONFIG_DUMP_ON_EXIT /* Dump task state on exit */ +#undef CONFIG_SUPPRESS_INTERRUPTS /* DEFINED: Do not enable interrupts */ +#undef CONFIG_SUPPRESS_TIMER_INTS /* DEFINED: No timer */ +#undef CONFIG_SUPPRESS_SERIAL_INTS /* DEFINED: Console will poll */ +#undef CONFIG_SUPPRESS_UART_CONFIG /* DEFINED: Do not reconfig UART */ +#undef CONFIG_DUMP_ON_EXIT /* DEFINED: Dump task state on exit */ /**************************************************************************** * Public Types diff --git a/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c index be32d269bc..7018f7b415 100644 --- a/arch/arm/src/dm320/dm320_serial.c +++ b/arch/arm/src/dm320/dm320_serial.c @@ -379,7 +379,7 @@ static int up_setup(struct uart_dev_s *dev) /* Setup the new UART configuration */ - up_serialout(priv,UART_MSR, priv->msr); + up_serialout(priv, UART_MSR, priv->msr); up_serialout(priv, UART_BRSR, brsr); up_enablebreaks(priv, FALSE); #endif diff --git a/arch/arm/src/dm320/dm320_uart.h b/arch/arm/src/dm320/dm320_uart.h index 8938018a75..0c5d803be4 100644 --- a/arch/arm/src/dm320/dm320_uart.h +++ b/arch/arm/src/dm320/dm320_uart.h @@ -70,24 +70,28 @@ #define UART_DTRR_DTR_MASK 0x00ff /* Data transmit/receive */ /* UART BRSR register bit definitions */ -/* The UART clock is half of the ARM clock */ +/* The UART module is clocked by either the AHB clock or PLLIN / 16 */ -#define UART_CLK (DM320_ARM_CLOCK / 2) +#ifdef CONFIG_DM320_UARTPPLIN +# define UART_REFCLK (27000000 / 16) +#else +# define UART_REFCLK (DM320_AHB_CLOCK / 16) +#endif -/* And baud rate = UART_CLK / 16 / (VALUE+1) */ +/* And baud = UART_REFCLK / (brsr+1) */ -#define UART_BAUD_2400 ((uint16)(((UART_CLK / 16) / 2400 ) - 1)) -#define UART_BAUD_4800 ((uint16)(((UART_CLK / 16) / 4800 ) - 1)) -#define UART_BAUD_9600 ((uint16)(((UART_CLK / 16) / 9600 ) - 1)) -#define UART_BAUD_14400 ((uint16)(((UART_CLK / 16) / 14400 ) - 1)) -#define UART_BAUD_19200 ((uint16)(((UART_CLK / 16) / 19200 ) - 1)) -#define UART_BAUD_28800 ((uint16)(((UART_CLK / 16) / 28800 ) - 1)) -#define UART_BAUD_38400 ((uint16)(((UART_CLK / 16) / 38400 ) - 1)) -#define UART_BAUD_57600 ((uint16)(((UART_CLK / 16) / 57600 ) - 1)) -#define UART_BAUD_115200 ((uint16)(((UART_CLK / 16) / 115200) - 1)) -#define UART_BAUD_230400 ((uint16)(((UART_CLK / 16) / 230400) - 1)) -#define UART_BAUD_460800 ((uint16)(((UART_CLK / 16) / 460800) - 1)) -#define UART_BAUD_921600 ((uint16)(((UART_CLK / 16) / 921600) - 1)) +#define UART_BAUD_2400 ((uint16)((UART_REFCLK / 2400 ) - 1)) +#define UART_BAUD_4800 ((uint16)((UART_REFCLK / 4800 ) - 1)) +#define UART_BAUD_9600 ((uint16)((UART_REFCLK / 9600 ) - 1)) +#define UART_BAUD_14400 ((uint16)((UART_REFCLK / 14400 ) - 1)) +#define UART_BAUD_19200 ((uint16)((UART_REFCLK / 19200 ) - 1)) +#define UART_BAUD_28800 ((uint16)((UART_REFCLK / 28800 ) - 1)) +#define UART_BAUD_38400 ((uint16)((UART_REFCLK / 38400 ) - 1)) +#define UART_BAUD_57600 ((uint16)((UART_REFCLK / 57600 ) - 1)) +#define UART_BAUD_115200 ((uint16)((UART_REFCLK / 115200) - 1)) +#define UART_BAUD_230400 ((uint16)((UART_REFCLK / 230400) - 1)) +#define UART_BAUD_460800 ((uint16)((UART_REFCLK / 460800) - 1)) +#define UART_BAUD_921600 ((uint16)((UART_REFCLK / 921600) - 1)) /* UART MSR register bit definitions */