#include
#include
#include
#include
#include
#include
#include
#include "gw_debug.h"
#include "uart.h"
//#define UART_DEBUG
static int support_baud[] = {
0, 50, 75, 110, 134, 150, 200,
300, 600, 1200, 1800, 2400, 4800, 9600,
19200, 38400, 57600, 115200, 230400,
};
int is_support_baud(int baud)
{
int i = 0;
for (i = 0; i < ARRAY_SIZE(support_baud); i++)
if (support_baud[i] == baud)
return 1;
return 0;
}
static speed_t int_to_speed(int baud)
{
if (is_support_baud(baud)) {
switch (baud) {
case 0:
return B0;
case 50:
return B50;
case 75:
return B75;
case 110:
return B110;
case 134:
return B134;
case 150:
return B150;
case 200:
return B200;
case 300:
return B300;
case 600:
return B600;
case 1200:
return B1200;
case 1800:
return B1800;
case 2400:
return B2400;
case 4800:
return B4800;
case 9600:
return B9600;
case 19200:
return B19200;
case 38400:
return B38400;
case 57600:
return B57600;
case 115200:
return B115200;
case 230400:
return B230400;
default:
return GW_FAIL;
}
}
retu