summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/termios_num2baud.c
blob: debc7e4b7e6cdf64ca28579c011a1854eb5742b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 *  COPYRIGHT (c) 1989-2008.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#include <sys/termios.h>

int termios_number_to_baud(
  int baud
)
{
  int termios_baud;

  switch (baud) {
    case 0:       termios_baud = B0;      break;
    case 50:      termios_baud = B50;     break;
    case 75:      termios_baud = B75;     break;
    case 110:     termios_baud = B110;    break;
    case 134:     termios_baud = B134;    break;
    case 150:     termios_baud = B150;    break;
    case 200:     termios_baud = B200;    break;
    case 300:     termios_baud = B300;    break;
    case 600:     termios_baud = B600;    break;
    case 1200:    termios_baud = B1200;   break;
    case 1800:    termios_baud = B1800;   break;
    case 2400:    termios_baud = B2400;   break;
    case 4800:    termios_baud = B4800;   break;
    case 9600:    termios_baud = B9600;   break;
    case 19200:   termios_baud = B19200;  break;
    case 38400:   termios_baud = B38400;  break;
    case 57600:   termios_baud = B57600;  break;
    case 115200:  termios_baud = B115200; break;
    case 230400:  termios_baud = B230400; break;
    case 460800:  termios_baud = B460800; break;
    default:      termios_baud = -1;      break;
  }

  return termios_baud;
}