2013-02-22 53 views
0
void NS16550_putc(NS16550_t com_port, char c) 
    { 
     while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0); 
    //write to the THR 
     serial_out(c, &com_port->thr); 
     if (c == '\n') 
    //why do we require to call this watch dog reset 
     WATCHDOG_RESET(); 
    } 

char NS16550_getc(NS16550_t com_port) 
    { 
     while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {  
    #ifdef CONFIG_USB_TTY  
     extern void usbtty_poll(void);  
     usbtty_poll();  
    #endif 
    //why do we require to call this watch dog reset 
     WATCHDOG_RESET();  
    } 
    //return the rbr value 
     return serial_in(&com_port->rbr); 
    } 

回答

0

我不知道这个代码的情况下。

但最有可能是因为你不想让你的操作持续这么长时间,看门狗超时(并重置您的设备......)

例如,

while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {  
    #ifdef CONFIG_USB_TTY  
     extern void usbtty_poll(void);  
     usbtty_poll();  
    #endif 
    //why do we require to call this watch dog reset 
     WATCHDOG_RESET();  
    } 

在上面的代码,你在这个while循环中反复验证一些条件,现在这个循环可能会运行很长时间,如果你没有重置你的看门狗定时器(或者踢你的看门狗),那么看门狗最终可能会超时。

+0

但while循环中的每次条件满足设备将被重置? – rohit 2013-02-27 05:00:06