Line 39... |
Line 39... |
#define LSR_BREAK (0x10)
|
#define LSR_BREAK (0x10)
|
#define LSR_TXFE (0x20)
|
#define LSR_TXFE (0x20)
|
#define LSR_TXE (0x40)
|
#define LSR_TXE (0x40)
|
#define LSR_ERR (0x80)
|
#define LSR_ERR (0x80)
|
|
|
#define UART_INT_LINE 4 /* To which interrupt is uart connected */
|
#define UART_INT_LINE 15 /* To which interrupt is uart connected */
|
|
|
/* fails if x is false */
|
/* fails if x is false */
|
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
|
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
|
/* Waits a few cycles that uart can prepare its data */
|
/* Waits a few cycles that uart can prepare its data */
|
#define WAIT() {asm ("l.nop");asm ("l.nop");asm ("l.nop");asm ("l.nop");}
|
#define WAIT() {asm ("l.nop");asm ("l.nop");asm ("l.nop");asm ("l.nop");}
|
Line 348... |
Line 348... |
/* Receive a break */
|
/* Receive a break */
|
send_char ('!');
|
send_char ('!');
|
MARK();
|
MARK();
|
while (!((x = getreg (UART_LSR)) & LSR_DR));
|
while (!((x = getreg (UART_LSR)) & LSR_DR));
|
/* we should receive zero character with broken frame and break bit should be set */
|
/* we should receive zero character with broken frame and break bit should be set */
|
printf("[%x]\n", (LSR_DR | LSR_FE | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
|
printf("[%x]\n", (LSR_DR | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (x == (LSR_DR | LSR_FE | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (x == (LSR_DR | LSR_BREAK | LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (getreg (UART_RBR) == 0);
|
ASSERT (getreg (UART_RBR) == 0);
|
MARK();
|
MARK();
|
|
|
/* Send a # to release break */
|
/* Send a # to release break */
|
setreg (UART_THR, '#');
|
setreg (UART_THR, '#');
|
Line 381... |
Line 381... |
/* Receive a break */
|
/* Receive a break */
|
send_char ('#');
|
send_char ('#');
|
while (!((x = getreg (UART_LSR)) & LSR_DR));
|
while (!((x = getreg (UART_LSR)) & LSR_DR));
|
/* we should receive zero character with broken frame and break bit
|
/* we should receive zero character with broken frame and break bit
|
should not be set, because we cleared it */
|
should not be set, because we cleared it */
|
printf("[%x:%x]\n", x, (LSR_DR | LSR_FE | LSR_BREAK |LSR_ERR | LSR_TXFE | LSR_TXE));
|
printf("[%x:%x]\n", x, (LSR_DR | LSR_BREAK |LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (x == (LSR_DR | LSR_FE | LSR_BREAK |LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (x == (LSR_DR | LSR_BREAK |LSR_ERR | LSR_TXFE | LSR_TXE));
|
ASSERT (getreg (UART_RBR) == 0);
|
ASSERT (getreg (UART_RBR) == 0);
|
MARK();
|
MARK();
|
send_char ('?');
|
send_char ('?');
|
MARK();
|
MARK();
|
while (!(getreg (UART_LSR) & LSR_DR));
|
while (!(getreg (UART_LSR) & LSR_DR));
|
Line 464... |
Line 464... |
setreg (UART_LCR, LCR_DIVL);
|
setreg (UART_LCR, LCR_DIVL);
|
setreg (UART_DLH, 2 >> 8);
|
setreg (UART_DLH, 2 >> 8);
|
setreg (UART_DLL, 2 & 0xff);
|
setreg (UART_DLL, 2 & 0xff);
|
setreg (UART_LCR, 0x03); /* 8N1 @ 2 */
|
setreg (UART_LCR, 0x03); /* 8N1 @ 2 */
|
MARK();
|
MARK();
|
|
while (!(getreg (UART_LSR) & 1)); /* Receive 'x' char */
|
|
getreg (UART_RBR);
|
|
MARK();
|
|
|
send_char ('T');
|
send_char ('T');
|
while (getreg (UART_LSR) != 0x60); /* Wait for THR to be empty */
|
while (getreg (UART_LSR) != 0x60); /* Wait for THR to be empty */
|
MARK();
|
MARK();
|
printf ("OK\n");
|
printf ("OK\n");
|
Line 484... |
Line 487... |
setreg (UART_LCR, LCR_DIVL);
|
setreg (UART_LCR, LCR_DIVL);
|
setreg (UART_DLH, 6 >> 8); /* Set relatively slow speed, so we can hanlde interrupts properly */
|
setreg (UART_DLH, 6 >> 8); /* Set relatively slow speed, so we can hanlde interrupts properly */
|
setreg (UART_DLL, 6 & 0xff);
|
setreg (UART_DLL, 6 & 0xff);
|
setreg (UART_LCR, 0x03); /* 8N1 @ 6 */
|
setreg (UART_LCR, 0x03); /* 8N1 @ 6 */
|
|
|
|
ASSERT (int_cnt == 0); /* We should not have got any interrupts before this test */
|
setreg (UART_IER, 0x07); /* Enable interrupts: line status, THR empty, data ready */
|
setreg (UART_IER, 0x07); /* Enable interrupts: line status, THR empty, data ready */
|
setreg (UART_FCR, 0x01); /* Set trigger level = 1 char, fifo should not be reset */
|
setreg (UART_FCR, 0x01); /* Set trigger level = 1 char, fifo should not be reset */
|
ASSERT (int_cnt == 0); /* We should not have got any interrupts before this test */
|
|
MARK();
|
MARK();
|
|
|
|
#if 0
|
|
while (!int_cnt); /* Clear previous THR interrupt */
|
|
ASSERT (--int_cnt == 0);
|
|
ASSERT (int_iir == 0xc2);
|
|
ASSERT ((int_lsr & 0xbe) == 0x20);
|
|
MARK();
|
|
#endif
|
|
|
/* I am configured - start interrupt test */
|
/* I am configured - start interrupt test */
|
send_char ('I');
|
send_char ('I');
|
while (!int_cnt); /* Wait for THR to be empty */
|
while (!int_cnt); /* Wait for THR to be empty */
|
ASSERT (--int_cnt == 0);
|
ASSERT (--int_cnt == 0);
|
ASSERT (int_iir == 0xc2);
|
ASSERT (int_iir == 0xc2);
|
Line 605... |
Line 616... |
MARK();
|
MARK();
|
|
|
while (!int_cnt); /* Wait for break interrupt */
|
while (!int_cnt); /* Wait for break interrupt */
|
ASSERT (--int_cnt == 0);
|
ASSERT (--int_cnt == 0);
|
ASSERT (int_iir == 0xc6);
|
ASSERT (int_iir == 0xc6);
|
ASSERT (int_lsr == 0xf9); /* BE flag should be set */
|
ASSERT (int_lsr == 0xf1); /* BE flag should be set */
|
ASSERT (getreg (UART_LSR) == 0x61); /* BE flag should be cleared by previous read */
|
ASSERT (getreg (UART_LSR) == 0x61); /* BE flag should be cleared by previous read */
|
MARK();
|
MARK();
|
recv_char (0);
|
recv_char (0);
|
MARK();
|
MARK();
|
|
|
Line 767... |
Line 778... |
|
|
register_test ();
|
register_test ();
|
init_8n1 ();
|
init_8n1 ();
|
// send_recv_test ();
|
// send_recv_test ();
|
// break_test ();
|
// break_test ();
|
// different_modes_test ();
|
different_modes_test ();
|
// interrupt_test ();
|
interrupt_test ();
|
// control_register_test ();
|
control_register_test ();
|
line_error_test ();
|
line_error_test ();
|
|
|
/* loopback_test ();
|
/* loopback_test ();
|
modem_test ();
|
modem_test ();
|
modem_error_test ();*/
|
modem_error_test ();*/
|