Last change
on this file since 221 was 215, checked in by gregli@…, 13 years ago |
More minor improvements to the serial server, in particular improved timeout recovery.
|
File size:
1.2 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 | #include "library.h"
|
---|
9 | #include <stdlib.h>
|
---|
10 | #include <string.h>
|
---|
11 |
|
---|
12 | struct baudRate supportedBaudRates[] =
|
---|
13 | {
|
---|
14 | { 2400, 0x0, "2400" },
|
---|
15 | { 4800, 0xff, "4800" },
|
---|
16 | { 9600, 0x1, "9600" },
|
---|
17 | { 19200, 0xff, "19.2K" },
|
---|
18 | { 38400, 0x2, "38.4K" },
|
---|
19 | { 76800, 0xff, "76.8K" },
|
---|
20 | { 115200, 0x3, "115.2K" },
|
---|
21 | { 153600, 0xff, "153.6K" },
|
---|
22 | { 230400, 0xff, "230.4K" },
|
---|
23 | { 460800, 0xff, "460.8K" },
|
---|
24 | { 0, 0, NULL }
|
---|
25 | };
|
---|
26 |
|
---|
27 | struct baudRate *baudRateMatchString( char *str )
|
---|
28 | {
|
---|
29 | struct baudRate *b;
|
---|
30 |
|
---|
31 | unsigned long a = atol( str );
|
---|
32 | if( a )
|
---|
33 | {
|
---|
34 | for( b = supportedBaudRates; b->rate; b++ )
|
---|
35 | if( b->rate == a || (b->rate / 1000) == a || ((b->rate + 500) / 1000) == a )
|
---|
36 | return( b );
|
---|
37 | }
|
---|
38 |
|
---|
39 | return( NULL );
|
---|
40 | }
|
---|
41 |
|
---|
42 | struct baudRate *baudRateMatchDivisor( unsigned char divisor )
|
---|
43 | {
|
---|
44 | struct baudRate *b;
|
---|
45 |
|
---|
46 | for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ )
|
---|
47 | ;
|
---|
48 |
|
---|
49 | return( b->rate ? b : NULL );
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.