Refactor serial configuratin; AVR teensy Kconfig now builds

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5092 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-09-05 12:45:35 +00:00
parent bdd2c5b288
commit 8870a08597
8 changed files with 385 additions and 374 deletions

View File

@ -6,6 +6,8 @@
config EXAMPLES_NSH
bool "NuttShell (NSH) example"
default n
select NSH_LIBRARY
select SYSTEM_READLINE
---help---
Enable the NuttShell (NSH) example

View File

@ -3260,4 +3260,5 @@
* Kconfig: Serial 2STOP setting must be integer 0/1, not a boolean.
* lib/misc/sendfile.c and include/sys/sendfile.h: Add a Linux style
sendfile() (non-standard!)
* Kconfig: Refactor serial settings (moved from chip to drivers/serial).
AVR "teensy" now builds with Kconfig (contributed by Richard Cochran).

View File

@ -256,6 +256,7 @@ config LPC43_TMR3
config LPC43_USART0
bool "USART0"
select ARCH_HAS_USART0
default n
config LPC43_UART1
@ -264,10 +265,12 @@ config LPC43_UART1
config LPC43_USART2
bool "USART2"
select ARCH_HAS_USART2
default n
config LPC43_USART3
bool "USART3"
select ARCH_HAS_USART3
default n
config LPC43_USB0
@ -289,64 +292,9 @@ config LPC43_WWDT
endmenu
menu "USART0 Configuration"
depends on LPC43_USART0
config USART0_SERIAL_CONSOLE
bool "USART0 serial console"
default y
---help---
Selects the USART0 for the console and ttys0 (default is the USART0).
config USART0_RXBUFSIZE
int "USART0 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART0_TXBUFSIZE
int "USART0 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART0_BAUD
int "USART0 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART0_BITS
int "USART0 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART0_PARITY
int "USART0 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART0_2STOP
int "USART0 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
endmenu
menu "UART1 Configuration"
depends on LPC43_UART1
config UART1_SERIAL_CONSOLE
bool "UART1 serial console"
default y if !LPC43_USART0
---help---
Selects the UART1 for the console and ttys0 (default is the UART1).
config UART1_RXBUFSIZE
int "UART1 Rx buffer size"
default 256
@ -387,104 +335,6 @@ config UART1_2STOP
endmenu
menu "USART2 Configuration"
depends on LPC43_USART2
config USART2_SERIAL_CONSOLE
bool "USART2 serial console"
default y if !LPC43_USART0 && !LPC43_UART1
---help---
Selects the USART2 for the console and ttys0 (default is the USART2).
config USART2_RXBUFSIZE
int "USART2 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART2_TXBUFSIZE
int "USART2 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART2_BAUD
int "USART2 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART2_BITS
int "USART2 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART2_PARITY
int "USART2 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART2_2STOP
int "USART2 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
endmenu
menu "USART3 Configuration"
depends on LPC43_USART3
config USART3_SERIAL_CONSOLE
bool "USART3 serial console"
default y if !LPC43_USART0 && !LPC43_UART1 && !LPC43_USART2
---help---
Selects the USART3 for the console and ttys0 (default is the USART3).
config USART3_RXBUFSIZE
int "USART3 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART3_TXBUFSIZE
int "USART3 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART3_BAUD
int "USART3 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART3_BITS
int "USART3 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART3_PARITY
int "USART3 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART3_2STOP
int "USART3 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
endmenu
config SERIAL_TERMIOS
bool "Serial driver TERMIOS supported"
depends on LPC43_USART0 || LPC43_UART1 || LPC43_USART2 || LPC43_USART3

View File

@ -288,14 +288,17 @@ config STM32_TIM14
config STM32_USART1
bool "USART1"
select ARCH_HAS_USART1
default n
config STM32_USART2
bool "USART2"
select ARCH_HAS_USART2
default n
config STM32_USART3
bool "USART3"
select ARCH_HAS_USART3
default n
config STM32_UART4
@ -309,6 +312,7 @@ config STM32_UART5
config STM32_USART6
bool "USART6"
default n
select ARCH_HAS_USART6
depends on STM32_STM32F20XX || STM32_STM32F40XX
config STM32_USB
@ -1420,53 +1424,6 @@ config STM32_TIM14_DAC2
endchoice
menu "USART1 Configuration"
depends on STM32_USART1
config USART1_SERIAL_CONSOLE
bool "USART1 serial console"
default y
---help---
Selects the USART1 for the console and ttys0 (default is the USART1).
config USART1_RXBUFSIZE
int "USART1 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART1_TXBUFSIZE
int "USART1 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART1_BAUD
int "USART1 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART1_BITS
int "USART1 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART1_PARITY
int "USART1 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART1_2STOP
int "USART1 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config USART1_RXDMA
bool "USART1 Rx DMA"
default n
@ -1474,55 +1431,6 @@ config USART1_RXDMA
---help---
In high data rate usage, Rx DMA may eliminate Rx overrun errors
endmenu
menu "USART2 Configuration"
depends on STM32_USART2
config USART2_SERIAL_CONSOLE
bool "USART2 serial console"
default y if !STM32_USART1
---help---
Selects the USART2 for the console and ttys0 (default is the USART2).
config USART2_RXBUFSIZE
int "USART2 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART2_TXBUFSIZE
int "USART2 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART2_BAUD
int "USART2 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART2_BITS
int "USART2 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART2_PARITY
int "USART2 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART2_2STOP
int "USART2 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config USART2_RXDMA
bool "USART2 Rx DMA"
default n
@ -1530,55 +1438,6 @@ config USART2_RXDMA
---help---
In high data rate usage, Rx DMA may eliminate Rx overrun errors
endmenu
menu "USART3 Configuration"
depends on STM32_USART3
config USART3_SERIAL_CONSOLE
bool "USART3 serial console"
default y if !STM32_USART1 && !STM32_USART2
---help---
Selects the USART3 for the console and ttys0 (default is the USART3).
config USART3_RXBUFSIZE
int "USART3 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART3_TXBUFSIZE
int "USART3 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART3_BAUD
int "USART3 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART3_BITS
int "USART3 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART3_PARITY
int "USART3 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART3_2STOP
int "USART3 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config USART3_RXDMA
bool "USART3 Rx DMA"
default n
@ -1586,8 +1445,6 @@ config USART3_RXDMA
---help---
In high data rate usage, Rx DMA may eliminate Rx overrun errors
endmenu
menu "UART4 Configuration"
depends on STM32_UART4
@ -1700,53 +1557,6 @@ config UART5_RXDMA
endmenu
menu "USART6 Configuration"
depends on STM32_USART6
config USART6_SERIAL_CONSOLE
bool "USART6 serial console"
default y if !STM32_USART1 && !STM32_USART2 && !STM32_USART3 && !STM32_UART4 && !STM32_UART5
---help---
Selects the USART6 for the console and ttys0 (default is the USART6).
config USART6_RXBUFSIZE
int "USART6 Rx buffer size"
default 256
---help---
Characters are buffered as received. This specific the size of the receive
buffer.
config USART6_TXBUFSIZE
int "USART6 Tx buffer size"
default 256
---help---
Characters are buffered before being sent. This specific the size of the
transmit buffer
config USART6_BAUD
int "USART6 BAUD"
default 11520
---help---
The configured BAUD of the UART
config USART6_BITS
int "USART6 number of bits"
default 8
---help---
The number of bits. Must be either 7 or 8.
config USART6_PARITY
int "USART6 parity"
default 0
---help---
0=no parity, 1=odd parity, 2=even parity
config USART6_2STOP
int "USART6 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config USART6_RXDMA
bool "USART6 Rx DMA"
default n
@ -1754,8 +1564,6 @@ config USART6_RXDMA
---help---
In high data rate usage, Rx DMA may eliminate Rx overrun errors
endmenu
config SERIAL_TERMIOS
bool "Serial driver TERMIOS supported"
depends on STM32_USART1 || STM32_USART2 || STM32_USART3 || STM32_UART4 || STM32_UART5 || STM32_USART6

View File

@ -116,4 +116,12 @@ source arch/avr/src/atmega/Kconfig
source arch/avr/src/avr32/Kconfig
source arch/avr/src/at32uc3/Kconfig
config AVR_USART0
bool "USART0 specific serial device driver settings"
select ARCH_HAS_USART0
config AVR_USART1
bool "USART1 specific serial device driver settings"
select ARCH_HAS_USART1
endif

View File

@ -909,12 +909,6 @@ endmenu
menu "UART1 Configuration"
depends on PIC32MX_UART1
config UART1_SERIAL_CONSOLE
bool "UART1 serial console"
default y
---help---
Selects the UART1 for the console and ttys0. Default: UART1 (if enabled).
config UART1_RXBUFSIZE
int "UART1 Rx buffer size"
default 256
@ -956,12 +950,6 @@ endmenu
menu "UART2 Configuration"
depends on PIC32MX_UART2
config UART2_SERIAL_CONSOLE
bool "UART2 serial console"
default y if !PIC32MX_UART1
---help---
Selects the UART2 for the console and ttys0. Default: UART2 (if enabled).
config UART2_RXBUFSIZE
int "UART2 Rx buffer size"
default 256
@ -1003,12 +991,6 @@ endmenu
menu "UART3 Configuration"
depends on PIC32MX_UART3
config UART3_SERIAL_CONSOLE
bool "UART3 serial console"
default y if !PIC32MX_UART1 && !PIC32MX_UART2
---help---
Selects the UART3 for the console and ttys0. Default: UART3 (if enabled).
config UART3_RXBUFSIZE
int "UART3 Rx buffer size"
default 256

View File

@ -282,4 +282,358 @@ config CONFIG_SERIAL_NPOLLWAITERS
endif
#
# USARTn_XYZ settings
#
config ARCH_HAS_USART0
bool
config ARCH_HAS_USART1
bool
config ARCH_HAS_USART2
bool
config ARCH_HAS_USART3
bool
config ARCH_HAS_USART4
bool
config ARCH_HAS_USART5
bool
config ARCH_HAS_USART6
bool
choice
prompt "Serial console"
depends on ARCH_HAS_USART0 || \
ARCH_HAS_USART1 || ARCH_HAS_USART2 || ARCH_HAS_USART3 || \
ARCH_HAS_USART4 || ARCH_HAS_USART5 || ARCH_HAS_USART6
config USART0_SERIAL_CONSOLE
bool "USART0"
depends on ARCH_HAS_USART0
config USART1_SERIAL_CONSOLE
bool "USART1"
depends on ARCH_HAS_USART1
config USART2_SERIAL_CONSOLE
bool "USART2"
depends on ARCH_HAS_USART2
config USART3_SERIAL_CONSOLE
bool "USART3"
depends on ARCH_HAS_USART3
config USART4_SERIAL_CONSOLE
bool "USART4"
depends on ARCH_HAS_USART4
config USART5_SERIAL_CONSOLE
bool "USART5"
depends on ARCH_HAS_USART5
config USART6_SERIAL_CONSOLE
bool "USART6"
depends on ARCH_HAS_USART6
endchoice
menu "USART0 Configuration"
depends on ARCH_HAS_USART0
config USART0_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART0_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART0_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART0_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART0_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART0_2STOP
int "use 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART1 Configuration"
depends on ARCH_HAS_USART1
config USART1_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART1_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART1_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART1_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART1_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART1_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART2 Configuration"
depends on ARCH_HAS_USART2
config USART2_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART2_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART2_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART2_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART2_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART2_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART3 Configuration"
depends on ARCH_HAS_USART3
config USART3_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART3_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART3_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART3_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART3_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART3_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART4 Configuration"
depends on ARCH_HAS_USART4
config USART4_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART4_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART4_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART4_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART4_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART4_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART5 Configuration"
depends on ARCH_HAS_USART5
config USART5_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART5_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART5_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART5_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART5_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART5_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu
menu "USART6 Configuration"
depends on ARCH_HAS_USART6
config USART6_RXBUFSIZE
int "receive buffer size"
default 256
help
Characters are buffered as they are received. This specifies
the size of the receive buffer.
config USART6_TXBUFSIZE
int "transmit buffer size"
default 256
help
Characters are buffered before being sent. This specifies
the size of the transmit buffer.
config USART6_BAUD
int "baud rate"
default 11520
help
The configured BAUD of the USART.
config USART6_BITS
int "character size"
default 8
help
The number of bits. Must be either 7 or 8.
config USART6_PARITY
int "parity setting"
default 0
help
0=no parity, 1=odd parity, 2=even parity
config USART6_2STOP
int "uses 2 stop bits"
default 0
help
1=Two stop bits
endmenu

View File

@ -125,7 +125,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
if (offset)
{
/* Use lseek to get the current position */
/* Use lseek to get the current file position */
startpos = lseek(infd, 0, SEEK_CUR);
if (startpos == (off_t)-1)
@ -133,7 +133,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
return ERROR;
}
/* Use lseek again to set the new position */
/* Use lseek again to set the new file position */
if (lseek(infd, *offset, SEEK_SET) == (off_t)-1)
{
@ -209,9 +209,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
wrbuffer = iobuffer;
do
{
/* Write the buffer of data to the outfd */
nbyteswritten = write(outfd, wrbuffer, nbytesread);
/* Check for a complete (or parial write). write() should not
/* Check for a complete (or parial) write. write() should not
* return zero.
*/
@ -261,11 +263,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
free(iobuffer);
/* Get the current file position */
/* Return the current file position */
if (offset)
{
/* Use lseek to get the current position */
/* Use lseek to get the current file position */
off_t curpos = lseek(infd, 0, SEEK_CUR);
if (curpos == (off_t)-1)
@ -277,7 +279,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
*offset = curpos;
/* Use lseek again to restore the original position */
/* Use lseek again to restore the original file position */
if (lseek(infd, startpos, SEEK_SET) == (off_t)-1)
{
@ -285,6 +287,10 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
}
}
/* Finally return the number of bytes actually transferred (or ERROR
* if any failure occurred).
*/
return ntransferred;
}