Created
October 8, 2013 20:41
-
-
Save dagon666/6891271 to your computer and use it in GitHub Desktop.
serial_stdio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _serial_putc(char c, FILE *stream) { | |
| if ('\n' == c) { | |
| _serial_putc('\r', stream); | |
| } | |
| while (!serial_sendc(c)); | |
| } | |
| char _serial_getc(FILE *stream) { | |
| unsigned char c = 0x00; | |
| while (!serial_getc(&c)); | |
| return (char)c; | |
| } | |
| void serial_install_stdio() { | |
| static FILE uart_stdout = FDEV_SETUP_STREAM(_serial_putc, NULL, _FDEV_SETUP_WRITE); | |
| static FILE uart_stdin = FDEV_SETUP_STREAM(NULL, _serial_getc, _FDEV_SETUP_READ); | |
| stdout = &uart_stdout; | |
| stdin = &uart_stdin; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment