Fix LM4F120 LaunchPad serial output. Add support for all 7 LM4F120 UARTs

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5782 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-03-24 20:40:40 +00:00
parent fde971ed5d
commit c568203ddc
8 changed files with 703 additions and 186 deletions
+6 -1
View File
@@ -4443,4 +4443,9 @@
* arch/arm/src/lm, kinetis, lpc32, and nuc1xx: Add kernel build
support to all ARMv7-M and ARMv6-M chips. There are no
configurations in place to to verify these additions!
(2013-03-24).
* arch/arm/src/lm/lm_gpio.h: Correct typos in alternate function
definitions (2013-03-23).
* arch/arm/src/lm/lm_lowputc.c and lm_serial.c: Add support for
the 7 UARTs on the LM4F120 (2013-03-23).
+2 -2
View File
@@ -167,8 +167,8 @@
# define GPIO_UART1_RX_2 (GPIO_FUNC_PFINPUT | GPIO_ALT_2 | GPIO_PORTC | GPIO_PIN_4)
# define GPIO_UART1_TX_1 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_1 | GPIO_PORTB | GPIO_PIN_1)
# define GPIO_UART1_TX_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_2 | GPIO_PORTC | GPIO_PIN_5)
# define GPIO_UART2_RX_1 (GPIO_FUNC_PFINPUT | GPIO_ALT_1 | GPIO_PORTD | GPIO_PIN_6)
# define GPIO_UART2_TX_2 (GPIO_FUNC_PFOUTPUT | GPIO_ALT_1 | GPIO_PORTD | GPIO_PIN_7)
# define GPIO_UART2_RX (GPIO_FUNC_PFINPUT | GPIO_ALT_1 | GPIO_PORTD | GPIO_PIN_6)
# define GPIO_UART2_TX (GPIO_FUNC_PFOUTPUT | GPIO_ALT_1 | GPIO_PORTD | GPIO_PIN_7)
# define GPIO_UART3_RX (GPIO_FUNC_PFINPUT | GPIO_ALT_1 | GPIO_PORTC | GPIO_PIN_6)
# define GPIO_UART3_TX (GPIO_FUNC_PFOUTPUT | GPIO_ALT_1 | GPIO_PORTC | GPIO_PIN_7)
# define GPIO_UART4_RX (GPIO_FUNC_PFINPUT | GPIO_ALT_1 | GPIO_PORTC | GPIO_PIN_4)
+18 -18
View File
@@ -123,24 +123,24 @@
#ifdef LM4F
# define GPIO_ALT_SHIFT 16 /* Bits 16-19: Alternate function */
# define GPIO_ALT_MASK (15 << GPIO_INT_SHIFT)
# define GPIO_ALT(n) ((n) << GPIO_INT_SHIFT)
# define GPIO_ALT_NONE (0 << GPIO_INT_SHIFT)
# define GPIO_ALT_1 (1 << GPIO_INT_SHIFT)
# define GPIO_ALT_2 (2 << GPIO_INT_SHIFT)
# define GPIO_ALT_3 (3 << GPIO_INT_SHIFT)
# define GPIO_ALT_4 (4 << GPIO_INT_SHIFT)
# define GPIO_ALT_5 (5 << GPIO_INT_SHIFT)
# define GPIO_ALT_6 (6 << GPIO_INT_SHIFT)
# define GPIO_ALT_7 (7 << GPIO_INT_SHIFT)
# define GPIO_ALT_8 (8 << GPIO_INT_SHIFT)
# define GPIO_ALT_9 (9 << GPIO_INT_SHIFT)
# define GPIO_ALT_10 (10 << GPIO_INT_SHIFT)
# define GPIO_ALT_11 (11 << GPIO_INT_SHIFT)
# define GPIO_ALT_12 (12 << GPIO_INT_SHIFT)
# define GPIO_ALT_13 (13 << GPIO_INT_SHIFT)
# define GPIO_ALT_14 (14 << GPIO_INT_SHIFT)
# define GPIO_ALT_15 (15 << GPIO_INT_SHIFT)
# define GPIO_ALT_MASK (15 << GPIO_ALT_SHIFT)
# define GPIO_ALT(n) ((n) << GPIO_ALT_SHIFT)
# define GPIO_ALT_NONE (0 << GPIO_ALT_SHIFT)
# define GPIO_ALT_1 (1 << GPIO_ALT_SHIFT)
# define GPIO_ALT_2 (2 << GPIO_ALT_SHIFT)
# define GPIO_ALT_3 (3 << GPIO_ALT_SHIFT)
# define GPIO_ALT_4 (4 << GPIO_ALT_SHIFT)
# define GPIO_ALT_5 (5 << GPIO_ALT_SHIFT)
# define GPIO_ALT_6 (6 << GPIO_ALT_SHIFT)
# define GPIO_ALT_7 (7 << GPIO_ALT_SHIFT)
# define GPIO_ALT_8 (8 << GPIO_ALT_SHIFT)
# define GPIO_ALT_9 (9 << GPIO_ALT_SHIFT)
# define GPIO_ALT_10 (10 << GPIO_ALT_SHIFT)
# define GPIO_ALT_11 (11 << GPIO_ALT_SHIFT)
# define GPIO_ALT_12 (12 << GPIO_ALT_SHIFT)
# define GPIO_ALT_13 (13 << GPIO_ALT_SHIFT)
# define GPIO_ALT_14 (14 << GPIO_ALT_SHIFT)
# define GPIO_ALT_15 (15 << GPIO_ALT_SHIFT)
#endif
/* If the pin is an GPIO digital output, then this identifies the initial output value:
+88 -37
View File
@@ -54,41 +54,8 @@
/**************************************************************************
* Pre-processor Definitions
**************************************************************************/
/* Configuration **********************************************************/
#if LM_NUARTS < 2
# undef CONFIG_LM_UART1
# undef CONFIG_UART1_SERIAL_CONSOLE
#endif
#if LM_NUARTS < 3
# undef CONFIG_LM_UART2
# undef CONFIG_UART2_SERIAL_CONSOLE
#endif
/* Is there a serial console? */
#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_LM_UART0)
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# define HAVE_CONSOLE 1
#elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_LM_UART1)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# define HAVE_CONSOLE 1
#elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# define HAVE_CONSOLE 1
#else
# warning "No valid CONFIG_UARTn_SERIAL_CONSOLE Setting"
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef HAVE_CONSOLE
#endif
/* Select UART parameters for the selected console */
#if defined(CONFIG_UART0_SERIAL_CONSOLE)
@@ -109,6 +76,36 @@
# define LM_CONSOLE_BITS CONFIG_UART2_BITS
# define LM_CONSOLE_PARITY CONFIG_UART2_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART2_2STOP
#elif defined(CONFIG_UART3_SERIAL_CONSOLE)
# define LM_CONSOLE_BASE LM_UART2_BASE
# define LM_CONSOLE_BAUD CONFIG_UART3_BAUD
# define LM_CONSOLE_BITS CONFIG_UART3_BITS
# define LM_CONSOLE_PARITY CONFIG_UART3_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART3_2STOP
#elif defined(CONFIG_UART4_SERIAL_CONSOLE)
# define LM_CONSOLE_BASE LM_UART2_BASE
# define LM_CONSOLE_BAUD CONFIG_UART4_BAUD
# define LM_CONSOLE_BITS CONFIG_UART4_BITS
# define LM_CONSOLE_PARITY CONFIG_UART4_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART4_2STOP
#elif defined(CONFIG_UART5_SERIAL_CONSOLE)
# define LM_CONSOLE_BASE LM_UART2_BASE
# define LM_CONSOLE_BAUD CONFIG_UART5_BAUD
# define LM_CONSOLE_BITS CONFIG_UART5_BITS
# define LM_CONSOLE_PARITY CONFIG_UART5_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART5_2STOP
#elif defined(CONFIG_UART6_SERIAL_CONSOLE)
# define LM_CONSOLE_BASE LM_UART2_BASE
# define LM_CONSOLE_BAUD CONFIG_UART6_BAUD
# define LM_CONSOLE_BITS CONFIG_UART6_BITS
# define LM_CONSOLE_PARITY CONFIG_UART6_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART6_2STOP
#elif defined(CONFIG_UART7_SERIAL_CONSOLE)
# define LM_CONSOLE_BASE LM_UART2_BASE
# define LM_CONSOLE_BAUD CONFIG_UART7_BAUD
# define LM_CONSOLE_BITS CONFIG_UART7_BITS
# define LM_CONSOLE_PARITY CONFIG_UART7_PARITY
# define LM_CONSOLE_2STOP CONFIG_UART7_2STOP
#else
# error "No CONFIG_UARTn_SERIAL_CONSOLE Setting"
#endif
@@ -226,7 +223,7 @@
void up_lowputc(char ch)
{
#ifdef HAVE_CONSOLE
#ifdef HAVE_SERIAL_CONSOLE
/* Wait until the TX FIFO is not full */
while ((getreg32(LM_CONSOLE_BASE+LM_UART_FR_OFFSET) & UART_FR_TXFF) != 0);
@@ -250,11 +247,11 @@ void up_lowputc(char ch)
void up_lowsetup(void)
{
uint32_t regval;
#if defined(HAVE_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
#if defined(HAVE_SERIAL_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
uint32_t ctl;
#endif
/* Enable the selected UARTs and configure GPIO pins to need by the
/* Enable the selected UARTs and configure GPIO pins needed by the
* the selected UARTs. NOTE: The serial driver later depends on
* this pin configuration -- whether or not a serial console is selected.
*/
@@ -277,9 +274,63 @@ void up_lowsetup(void)
lm_configgpio(GPIO_UART1_TX);
#endif
#ifdef CONFIG_LM_UART2
regval = getreg32(LM_SYSCON_RCGC1);
regval |= SYSCON_RCGC1_UART2;
putreg32(regval, LM_SYSCON_RCGC1);
lm_configgpio(GPIO_UART2_RX);
lm_configgpio(GPIO_UART2_TX);
#endif
#ifdef CONFIG_LM_UART3
regval = getreg32(LM_SYSCON_RCGCUART);
regval |= SYSCON_RCGCUART_R3;
putreg32(regval, LM_SYSCON_RCGCUART);
lm_configgpio(GPIO_UART3_RX);
lm_configgpio(GPIO_UART3_TX);
#endif
#ifdef CONFIG_LM_UART4
regval = getreg32(LM_SYSCON_RCGCUART);
regval |= SYSCON_RCGCUART_R4;
putreg32(regval, LM_SYSCON_RCGCUART);
lm_configgpio(GPIO_UART4_RX);
lm_configgpio(GPIO_UART4_TX);
#endif
#ifdef CONFIG_LM_UART5
regval = getreg32(LM_SYSCON_RCGCUART);
regval |= SYSCON_RCGCUART_R5;
putreg32(regval, LM_SYSCON_RCGCUART);
lm_configgpio(GPIO_UART5_RX);
lm_configgpio(GPIO_UART5_TX);
#endif
#ifdef CONFIG_LM_UART6
regval = getreg32(LM_SYSCON_RCGCUART);
regval |= SYSCON_RCGCUART_R6;
putreg32(regval, LM_SYSCON_RCGCUART);
lm_configgpio(GPIO_UART6_RX);
lm_configgpio(GPIO_UART6_TX);
#endif
#ifdef CONFIG_LM_UART7
regval = getreg32(LM_SYSCON_RCGCUART);
regval |= SYSCON_RCGCUART_R7;
putreg32(regval, LM_SYSCON_RCGCUART);
lm_configgpio(GPIO_UART7_RX);
lm_configgpio(GPIO_UART7_TX);
#endif
/* Enable the selected console device */
#if defined(HAVE_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
#if defined(HAVE_SERIAL_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
/* Disable the UART by clearing the UARTEN bit in the UART CTL register */
ctl = getreg32(LM_CONSOLE_BASE+LM_UART_CTL_OFFSET);
+118
View File
@@ -45,6 +45,124 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration *******************************************************************/
#if LM_NUARTS < 8
# undef CONFIG_LM_UART7
# undef CONFIG_UART7_SERIAL_CONSOLE
# if LM_NUARTS < 7
# undef CONFIG_LM_UART6
# undef CONFIG_UART6_SERIAL_CONSOLE
# if LM_NUARTS < 6
# undef CONFIG_LM_UART5
# undef CONFIG_UART5_SERIAL_CONSOLE
# if LM_NUARTS < 5
# undef CONFIG_LM_UART4
# undef CONFIG_UART4_SERIAL_CONSOLE
# if LM_NUARTS < 4
# undef CONFIG_LM_UART3
# undef CONFIG_UART3_SERIAL_CONSOLE
# if LM_NUARTS < 3
# undef CONFIG_LM_UART2
# undef CONFIG_UART2_SERIAL_CONSOLE
# if LM_NUARTS < 2
# undef CONFIG_LM_UART1
# undef CONFIG_UART1_SERIAL_CONSOLE
# endif
# endif
# endif
# endif
# endif
# endif
#endif
/* Is there a serial console? */
#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_LM_UART0)
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_LM_UART1)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART6_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_UART7_SERIAL_CONSOLE) && defined(CONFIG_LM_UART2)
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#else
# warning "No valid CONFIG_UARTn_SERIAL_CONSOLE Setting"
# undef CONFIG_UART0_SERIAL_CONSOLE
# undef CONFIG_UART1_SERIAL_CONSOLE
# undef CONFIG_UART2_SERIAL_CONSOLE
# undef CONFIG_UART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_UART6_SERIAL_CONSOLE
# undef CONFIG_UART7_SERIAL_CONSOLE
# undef HAVE_SERIAL_CONSOLE
#endif
/************************************************************************************
* Public Types
File diff suppressed because it is too large Load Diff
+45
View File
@@ -15,6 +15,7 @@ Contents
NuttX OABI "buildroot" Toolchain
NXFLAT Toolchain
LEDs
Serial Console
USB Device Controller Functions
Using OpenOCD and GDB with an FT2232 JTAG emulator
LM4F120 LaunchPad Configuration Options
@@ -466,6 +467,50 @@ LEDs
- In the event of a fatal crash, the BLUE and GREEN components will be
extinguished and the RED component will FLASH at a 2Hz rate.
Serial Console
^^^^^^^^^^^^^^
By default, all configurations use UART0 which connects to the USB VCOM
on the DEBUG port on the LM4F120 LaunchPad:
UART0 RX - PA.0
UART0 TX - PA.1
However, if you use an external RS232 driver, then other options are
available. UART1 has option pin settings and flow control capabilities
that are not available with the other UARTS::
UART1 RX - PB.0 or PC.4 (Need disambiguation in board.h)
UART1 TX - PB.1 or PC.5 (" " " " "" " ")
UART1_RTS - PF.0 or PC.4
UART1_CTS - PF.1 or PC.5
NOTE: board.h currently selects PB.0, PB.1, PF.0 and PF.1 for UART1, but
that can be changed by editting board.h
UART2-5, 7 are also available, UART2 is not recommended because it shares
some pin usage with USB device mode. UART6 is not available because its
only RX/TX pin options are dedicated to USB support.
UART2 RX - PD.6
UART2 TX - PD.7 (Also used for USB VBUS detection)
UART3 RX - PC.6
UART3 TX - PC.7
UART4 RX - PC.4
UART4 TX - PC.5
UART5 RX - PE.4
UART5 TX - PE.5
UART6 RX - PD.4, Not available. Dedicated for USB_DM
UART6 TX - PD.5, Not available. Dedicated for USB_DP
UART7 RX - PE.0
UART7 TX - PE.1
USB Device Controller Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -158,6 +158,13 @@
#define BUTTON_SW1_BIT (1 << BUTTON_SW1)
#define BUTTON_SW2_BIT (1 << BUTTON_SW2)
/* Pin Multiplexing Disambiguation **************************************************/
#define GPIO_UART1_CTS GPIO_UART1_CTS_1
#define GPIO_UART1_RTS GPIO_UART1_RTS_1
#define GPIO_UART1_RX GPIO_UART1_RX_1
#define GPIO_UART1_TX GPIO_UART1_TX_1
/************************************************************************************
* Public Function Prototypes
************************************************************************************/