summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-06 20:21:57 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-06 20:21:57 +0000
commit2cb26d0787b41ae1dc7607ef11ac11047491d7dc (patch)
tree0bfa100d6337879837dd6abf9612a0a7f889129b /nuttx/arch
parent829c1351e2be18265cd8ea8c481eec674192a6d5 (diff)
downloadpx4-nuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.tar.gz
px4-nuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.tar.bz2
px4-nuttx-2cb26d0787b41ae1dc7607ef11ac11047491d7dc.zip
Add support for use of a USB serial device to provide NSH console I/O. Verified on the Sure PIPIC32MX board
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4458 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-config.h4
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-head.S4
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-internal.h6
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-lowconsole.c94
4 files changed, 58 insertions, 50 deletions
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-config.h b/nuttx/arch/mips/src/pic32mx/pic32mx-config.h
index 689a6d261..990ebd09e 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-config.h
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-config.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/mips/src/pic32mx/pic32mx-config.h
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -538,7 +538,7 @@
# define HAVE_UART_DEVICE 1
#endif
-/* Is there a serial console? There should be at most one defined. It
+/* Is there a serial console? There should be no more than one defined. It
* could be on any UARTn, n=1,.. CHIP_NUARTS
*/
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-head.S b/nuttx/arch/mips/src/pic32mx/pic32mx-head.S
index 67f2aea3a..a0a775790 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-head.S
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-head.S
@@ -1,8 +1,8 @@
/****************************************************************************
* arch/mips/src/pic32mx/pic32mx-head.S
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-internal.h b/nuttx/arch/mips/src/pic32mx/pic32mx-internal.h
index 3697fad45..190fd8a47 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-internal.h
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-internal.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/mips/src/pic32mx/pic32mx-internal.h
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -181,7 +181,11 @@ EXTERN void pic32mx_lowinit(void);
*
************************************************************************************/
+#ifdef HAVE_SERIAL_CONSOLE
EXTERN void pic32mx_consoleinit(void);
+#else
+# define pic32mx_consoleinit()
+#endif
/******************************************************************************
* Name: pic32mx_uartreset
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-lowconsole.c b/nuttx/arch/mips/src/pic32mx/pic32mx-lowconsole.c
index 28c7f121f..b5ed42a8c 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-lowconsole.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-lowconsole.c
@@ -1,7 +1,7 @@
/******************************************************************************
* arch/mips/src/pic32mx/pic32mx-lowconsole.c
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -57,44 +57,46 @@
/* Select UART parameters for the selected console */
-#if defined(CONFIG_UART1_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART1_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART1_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART1_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART1_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART1_2STOP
-#elif defined(CONFIG_UART2_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART2_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART2_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART2_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART2_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART2_2STOP
-#elif defined(CONFIG_UART3_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART3_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART3_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART3_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART3_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART3_2STOP
-#elif defined(CONFIG_UART4_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART4_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART4_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART4_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART4_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART4_2STOP
-#elif defined(CONFIG_UART5_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART5_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART5_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART5_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART5_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART5_2STOP
-#elif defined(CONFIG_UART6_SERIAL_CONSOLE)
-# define PIC32MX_CONSOLE_BASE PIC32MX_UART6_K1BASE
-# define PIC32MX_CONSOLE_BAUD CONFIG_UART6_BAUD
-# define PIC32MX_CONSOLE_BITS CONFIG_UART6_BITS
-# define PIC32MX_CONSOLE_PARITY CONFIG_UART6_PARITY
-# define PIC32MX_CONSOLE_2STOP CONFIG_UART6_2STOP
-#else
-# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
+#ifdef HAVE_SERIAL_CONSOLE
+# if defined(CONFIG_UART1_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART1_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART1_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART1_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART1_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART1_2STOP
+# elif defined(CONFIG_UART2_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART2_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART2_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART2_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART2_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART2_2STOP
+# elif defined(CONFIG_UART3_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART3_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART3_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART3_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART3_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART3_2STOP
+# elif defined(CONFIG_UART4_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART4_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART4_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART4_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART4_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART4_2STOP
+# elif defined(CONFIG_UART5_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART5_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART5_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART5_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART5_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART5_2STOP
+# elif defined(CONFIG_UART6_SERIAL_CONSOLE)
+# define PIC32MX_CONSOLE_BASE PIC32MX_UART6_K1BASE
+# define PIC32MX_CONSOLE_BAUD CONFIG_UART6_BAUD
+# define PIC32MX_CONSOLE_BITS CONFIG_UART6_BITS
+# define PIC32MX_CONSOLE_PARITY CONFIG_UART6_PARITY
+# define PIC32MX_CONSOLE_2STOP CONFIG_UART6_2STOP
+# else
+# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
+# endif
#endif
/******************************************************************************
@@ -318,31 +320,32 @@ void pic32mx_uartconfigure(uintptr_t uart_base, uint32_t baudrate,
* Name: pic32mx_consoleinit
*
* Description:
- * Initialize a console for debug output. This function is called very
- * early in the intialization sequence to configure the serial console uart
- * (only).
+ * Initialize a low-level console for debug output. This function is called
+ * very early in the intialization sequence to configure the serial console
+ * UART (only).
*
******************************************************************************/
+#ifdef HAVE_SERIAL_CONSOLE
void pic32mx_consoleinit(void)
{
-#ifdef HAVE_UART_DEVICE
pic32mx_uartconfigure(PIC32MX_CONSOLE_BASE, PIC32MX_CONSOLE_BAUD,
PIC32MX_CONSOLE_PARITY, PIC32MX_CONSOLE_BITS,
PIC32MX_CONSOLE_2STOP);
-#endif
}
+#endif
/******************************************************************************
* Name: up_lowputc
*
* Description:
- * Output one byte on the serial console
+ * Output one byte on the serial console.
*
******************************************************************************/
void up_lowputc(char ch)
{
+#ifdef HAVE_SERIAL_CONSOLE
/* Wait for the transmit buffer not full */
while ((pic32mx_getreg(PIC32MX_CONSOLE_BASE, PIC32MX_UART_STA_OFFSET) & UART_STA_UTXBF) != 0);
@@ -350,5 +353,6 @@ void up_lowputc(char ch)
/* Then write the character to the TX data register */
pic32mx_putreg(PIC32MX_CONSOLE_BASE, PIC32MX_UART_TXREG_OFFSET, (uint32_t)ch);
+#endif
}