在这两个函数中,为什么需要执行WATCHDOG_RESET()?
我不知道这段代码的上下文 但很可能是因为您不想让您的操作持续太长时间,以至于看门狗超时(并重置您的设备…) 比如说,在这两个函数中,为什么需要执行WATCHDOG_RESET()?,c,linux,C,Linux,我不知道这段代码的上下文 但很可能是因为您不想让您的操作持续太长时间,以至于看门狗超时(并重置您的设备…) 比如说, 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(v
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);
}
在上面的代码中,您正在这个while循环中重复验证某些条件,现在这个循环可能会运行很长时间,如果您不重置看门狗计时器(或踢踢看门狗),看门狗可能最终会超时。但是while循环中的每一次条件都满足,那么设备会重置吗?
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);
}
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();
}