int up_putc(int ch) { uint8_t state; /* Keep interrupts disabled so that we do not interfere with normal * driver operation. * * REVISIT: I can imagine scenarios where the follow logic gets pre-empted * and the the UART interrupts get left in a bad state. */ state = z16f_disableuartirq(&CONSOLE_DEV); /* Check for LF */ if (ch == '\n') { /* Add CR before LF */ z16f_consoleput('\r'); } /* Output the character */ z16f_consoleput((uint8_t)ch); /* It is important to restore the TX interrupt while the send is pending. * otherwise, TRDE interrupts can be lost since they do not pend after the * TRDE false->true transition. */ z16f_restoreuartirq(&CONSOLE_DEV, state); return ch; }
int up_putc(int ch) { uint8_t state; /* Keep interrupts disabled so that we do not interfere with normal * driver operation */ state = z16f_disableuartirq(&CONSOLE_DEV); /* Check for LF */ if (ch == '\n') { /* Add CR before LF */ z16f_consoleput('\r'); } /* Output the character */ z16f_consoleput((uint8_t)ch); /* It is important to restore the TX interrupt while the send is pending. * otherwise, TRDE interrupts can be lost since they do not pend after the * TRDE false->true transition. */ z16f_restoreuartirq(&CONSOLE_DEV, state); return ch; }