source: xtideuniversalbios/trunk/Serial_Server/library/Serial.cpp@ 578

Last change on this file since 578 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 2.0 KB
Line 
1//======================================================================
2//
3// Project: XTIDE Universal BIOS, Serial Port Server
4//
5// File: Serial.cpp - Generic functions for dealing with serial communications
6//
7
8//
9// XTIDE Universal BIOS and Associated Tools
10// Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
11//
12// This program is free software; you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation; either version 2 of the License, or
15// (at your option) any later version.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License for more details.
21// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22//
23
24#include "library.h"
25#include <stdlib.h>
26#include <string.h>
27
28struct baudRate supportedBaudRates[] =
29{
30 { 2400, 0x30, "2400" },
31 { 4800, 0x18, "4800" },
32 { 9600, 0xc, "9600" },
33 { 19200, 0xff, "19.2K" },
34 { 28800, 0x4, "28.8K" },
35 { 38400, 0xff, "38.4K" },
36 { 57600, 0x2, "57.6K" },
37 { 76800, 0xff, "76.8K" },
38 { 115200, 0x1, "115.2K" },
39 { 153600, 0xff, "153.6K" },
40 { 230400, 0xff, "230.4K" },
41 { 460800, 0xff, "460.8K" },
42 { 921600, 0xff, "921.6K" },
43 { 0, 0, "Unknown" },
44};
45
46struct baudRate *baudRateMatchString( char *str )
47{
48 struct baudRate *b;
49
50 unsigned long a = atol( str );
51 if( a )
52 {
53 for( b = supportedBaudRates; b->rate; b++ )
54 if( b->rate == a || (b->rate / 1000) == a || ((b->rate + 500) / 1000) == a )
55 return( b );
56 }
57
58 return( b );
59}
60
61struct baudRate *baudRateMatchDivisor( unsigned char divisor )
62{
63 struct baudRate *b;
64
65 for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ )
66 ;
67
68 return( b );
69}
70
71
Note: See TracBrowser for help on using the repository browser.