diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-10-18 15:51:41 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-10-18 15:51:41 +0000 |
commit | 664db30bd38371a14c82d61f78dde7db2cbed41d (patch) | |
tree | b48b1e1c5e41adb5762a59b3e177fb18367bc0e5 /c/src/lib/libbsp/i386/pc386/console/console.c | |
parent | 2000-10-18 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-664db30bd38371a14c82d61f78dde7db2cbed41d.tar.bz2 |
2000-10-18 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
* console/console.c, console/serial_mouse.c, include/bsp.h:
Add the ability to set parity, number of data bits and
number of stop bits to the existing i386 serial drivers.
Diffstat (limited to 'c/src/lib/libbsp/i386/pc386/console/console.c')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/console.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/console/console.c b/c/src/lib/libbsp/i386/pc386/console/console.c index 2293d81389..b93e0cc284 100644 --- a/c/src/lib/libbsp/i386/pc386/console/console.c +++ b/c/src/lib/libbsp/i386/pc386/console/console.c @@ -226,7 +226,7 @@ console_initialize(rtems_device_major_number major, * Do device-specific initialization */ /* 9600-8-N-1 */ - BSP_uart_init(BSPConsolePort, 9600, 0); + BSP_uart_init(BSPConsolePort, 9600, CHR_8_BITS, 0, 0, 0); /* Set interrupt handler */ @@ -454,7 +454,7 @@ console_control(rtems_device_major_number major, static int conSetAttr(int minor, const struct termios *t) { - int baud; + unsigned long baud, databits, parity, stopbits; switch (t->c_cflag & CBAUD) { @@ -510,12 +510,43 @@ conSetAttr(int minor, const struct termios *t) baud = 115200; break; default: - baud = 0; rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); return 0; } - BSP_uart_set_baud(BSPConsolePort, baud); + if (t->c_cflag & PARENB) { + /* Parity is enabled */ + if (t->c_cflag & PARODD) { + /* Parity is odd */ + parity = PEN; + } + else { + /* Parity is even */ + parity = PEN | EPS; + } + } + else { + /* No parity */ + parity = 0; + } + + switch (t->c_cflag & CSIZE) { + case CS5: databits = CHR_5_BITS; break; + case CS6: databits = CHR_6_BITS; break; + case CS7: databits = CHR_7_BITS; break; + case CS8: databits = CHR_8_BITS; break; + } + + if (t->c_cflag & CSTOPB) { + /* 2 stop bits */ + stopbits = STB; + } + else { + /* 1 stop bit */ + stopbits = 0; + } + + BSP_uart_set_attributes(BSPConsolePort, baud, databits, parity, stopbits); return 0; } |