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 に答える