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);
    }
4

1 回答 1

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循环中重复验证了一些条件,现在这个循环可能会运行很长时间,如果你不重置你的看门狗定时器(或踢你的看门狗),看门狗可能会超时最终。

于 2013-02-22T06:06:46.323 回答