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
This commit is contained in:
patacongo 2012-03-06 20:21:57 +00:00
parent 2e0bf2907e
commit ee1ff18a26
4 changed files with 58 additions and 50 deletions

View File

@ -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
*/

View File

@ -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

View File

@ -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

View File

@ -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
}