summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-03-11 14:39:32 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-03-11 14:39:32 -0600
commit9f99659800ab70c6575ced12c6a6d5450399e2aa (patch)
tree87a7d851ace1812fd3c53395caf89a9973ed7f8f /nuttx/arch
parentcd7c347d0f3435990fe54603ba8df015a42ec911 (diff)
downloadpx4-nuttx-9f99659800ab70c6575ced12c6a6d5450399e2aa.tar.gz
px4-nuttx-9f99659800ab70c6575ced12c6a6d5450399e2aa.tar.bz2
px4-nuttx-9f99659800ab70c6575ced12c6a6d5450399e2aa.zip
SAMV7: Correct low-level console output
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/arm/src/samv7/sam_lowputc.c17
-rw-r--r--nuttx/arch/arm/src/samv7/sam_serial.c12
2 files changed, 15 insertions, 14 deletions
diff --git a/nuttx/arch/arm/src/samv7/sam_lowputc.c b/nuttx/arch/arm/src/samv7/sam_lowputc.c
index 93e201df7..3484c65a0 100644
--- a/nuttx/arch/arm/src/samv7/sam_lowputc.c
+++ b/nuttx/arch/arm/src/samv7/sam_lowputc.c
@@ -47,6 +47,7 @@
#include "up_internal.h"
#include "up_arch.h"
+#include "sam_config.h"
#include "sam_gpio.h"
#include "sam_periphclks.h"
#include "sam_lowputc.h"
@@ -390,9 +391,10 @@ void sam_lowsetup(void)
* for lower USART clocks.
*/
- divb3 = ((FAST_USART_CLOCK + (priv->baud << 3)) << 3) / (priv->baud << 4);
+ divb3 = ((FAST_USART_CLOCK + (SAM_CONSOLE_BAUD << 3)) << 3) /
+ (SAM_CONSOLE_BAUD << 4);
intpart = (divb3 >> 3);
- fracpart = (divb3 & 7)
+ fracpart = (divb3 & 7);
/* Retain the fast MR peripheral clock UNLESS unless using that clock
* would result in an excessively large divider.
@@ -400,20 +402,21 @@ void sam_lowsetup(void)
* REVISIT: The fractional divider is not used.
*/
- if ((regval & UART_BRGR_CD_MASK) != 0)
+ if ((intpart & ~UART_BRGR_CD_MASK) != 0)
{
/* Use the divided USART clock */
- divb3 = ((FAST_USART_CLOCK + (priv->baud << 3)) << 3) / (priv->baud << 4);
+ divb3 = ((SLOW_USART_CLOCK + (SAM_CONSOLE_BAUD << 3)) << 3) /
+ (SAM_CONSOLE_BAUD << 4);
intpart = (divb3 >> 3);
- fracpart = (divb3 & 7)
+ fracpart = (divb3 & 7);
/* Re-select the clock source */
- regval = sam_serialin(priv, SAM_UART_MR_OFFSET);
+ regval = getreg32(SAM_CONSOLE_BASE + SAM_UART_MR_OFFSET);
regval &= ~UART_MR_USCLKS_MASK;
regval |= UART_MR_USCLKS_MCKDIV;
- sam_serialout(priv, SAM_UART_MR_OFFSET, regval);
+ putreg32(regval, SAM_CONSOLE_BASE + SAM_UART_MR_OFFSET);
}
/* Save the BAUD divider (the fractional part is not used for UARTs) */
diff --git a/nuttx/arch/arm/src/samv7/sam_serial.c b/nuttx/arch/arm/src/samv7/sam_serial.c
index 224e887ff..45005dcfb 100644
--- a/nuttx/arch/arm/src/samv7/sam_serial.c
+++ b/nuttx/arch/arm/src/samv7/sam_serial.c
@@ -68,10 +68,6 @@
* Pre-processor Definitions
****************************************************************************/
-/* If we are not using the serial driver for the console, then we still must
- * provide some minimal implementation of up_putc.
- */
-
#ifdef USE_SERIALDRIVER
/* Which UART/USART with be tty0/console and which tty1-7? */
@@ -870,7 +866,8 @@ static int sam_setup(struct uart_dev_s *dev)
* for lower USART clocks.
*/
- divb3 = ((FAST_USART_CLOCK + (priv->baud << 3)) << 3) / (priv->baud << 4);
+ divb3 = ((FAST_USART_CLOCK + (priv->baud << 3)) << 3) /
+ (priv->baud << 4);
intpart = divb3 >> 3;
fracpart = divb3 & 7;
@@ -880,11 +877,12 @@ static int sam_setup(struct uart_dev_s *dev)
* REVISIT: The fractional divider is not used.
*/
- if ((regval & UART_BRGR_CD_MASK) != 0)
+ if ((intpart & ~UART_BRGR_CD_MASK) != 0)
{
/* Use the divided USART clock */
- divb3 = ((FAST_USART_CLOCK + (priv->baud << 3)) << 3) / (priv->baud << 4);
+ divb3 = ((SLOW_USART_CLOCK + (priv->baud << 3)) << 3) /
+ (priv->baud << 4);
intpart = divb3 >> 3;
fracpart = divb3 & 7;