|
|
@@ -25,7 +25,22 @@
|
|
|
#define UART_MAX_FD 256 //noted by sunxi: 因为传进来的UART_CHANNEL[i]不一定是连续的。
|
|
|
|
|
|
//static int am335x_uarts_fd[CFG_UART_NUM_MAX];
|
|
|
-static int am335x_uarts_fd[UART_MAX_FD];
|
|
|
+static int am335x_uarts_fd[UART_MAX_FD] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
|
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,};
|
|
|
|
|
|
|
|
|
static void am335x_uarts_init(int channel)
|
|
|
@@ -232,16 +247,19 @@ int uart_open(int channel, uint32_t baudRate, int setting)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- am335x_uarts_init(channel);
|
|
|
- memset(tty_name,0,sizeof(tty_name));
|
|
|
- sprintf(tty_name, "/dev/ttyAS%d", channel); //sprintf(tty_name, "/dev/ttyO%d", channel); by ygl 2025.6.13
|
|
|
- am335x_uarts_fd[channel] = open(tty_name, O_RDWR, 0);
|
|
|
- if(am335x_uarts_fd[channel] < 0)
|
|
|
+ if (am335x_uarts_fd[channel] < 0)
|
|
|
{
|
|
|
- printf("open %s failed!\n", tty_name);
|
|
|
- return am335x_uarts_fd[channel];
|
|
|
- }
|
|
|
-
|
|
|
+ am335x_uarts_init(channel);
|
|
|
+ memset(tty_name,0,sizeof(tty_name));
|
|
|
+ sprintf(tty_name, "/dev/ttyAS%d", channel); //sprintf(tty_name, "/dev/ttyO%d", channel); by ygl 2025.6.13
|
|
|
+ am335x_uarts_fd[channel] = open(tty_name, O_RDWR, 0);
|
|
|
+ if(am335x_uarts_fd[channel] < 0)
|
|
|
+ {
|
|
|
+ printf("inside open %s failed!\n", tty_name);
|
|
|
+ return am335x_uarts_fd[channel];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
switch(setting)
|
|
|
{
|
|
|
case PARITY_EVEN://偶校验
|
|
|
@@ -379,7 +397,7 @@ void uart_putchar2 (int channel, char ch)
|
|
|
|
|
|
int uart_init(void)
|
|
|
{
|
|
|
- int i;
|
|
|
+ int i, ret;
|
|
|
|
|
|
for(i = 0; i < CFG_UART_NUM_MAX; i++)
|
|
|
{
|
|
|
@@ -388,7 +406,15 @@ int uart_init(void)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- uart_open(i,115200,PARITY_NONE);
|
|
|
+ ret = uart_open(i,115200,PARITY_NONE);
|
|
|
+ if (ret < 0)
|
|
|
+ {
|
|
|
+ printf("%s: outside uart %d open failed!\n", __FUNCTION__, i);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ printf("%s: outside uart %d open success!\n", __FUNCTION__, i);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return 0;
|