diff options
author | fishsoupisgood <github@madingley.org> | 2020-05-26 14:33:34 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-05-26 14:33:34 +0100 |
commit | f0d941bef6a9b6e3af78cfc68e1f82d6b47ccb2f (patch) | |
tree | 22a88d00cb28e075b5397ff5db586d548023f2f2 /stm32/app/stdio.c | |
download | heating-f0d941bef6a9b6e3af78cfc68e1f82d6b47ccb2f.tar.gz heating-f0d941bef6a9b6e3af78cfc68e1f82d6b47ccb2f.tar.bz2 heating-f0d941bef6a9b6e3af78cfc68e1f82d6b47ccb2f.zip |
happy
Diffstat (limited to 'stm32/app/stdio.c')
-rw-r--r-- | stm32/app/stdio.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/stm32/app/stdio.c b/stm32/app/stdio.c new file mode 100644 index 0000000..bcdd5c7 --- /dev/null +++ b/stm32/app/stdio.c @@ -0,0 +1,77 @@ +#include "project.h" + +unsigned block_stdio; + +int +_open (const char *name, int flags, int mode) +{ + errno = ENOSYS; + return -1; /* Always fails */ + +} /* _open () */ + +int +_close (int file) +{ + errno = EBADF; + return -1; /* Always fails */ + +} /* _close () */ + +int +_write (int file, char *buf, int nbytes) +{ + + int ret = nbytes; + + if (!block_stdio) + ret = usart1_write (buf, nbytes, 1); + + if (ret < 0) { + errno = -ret; + return -1; + } + + return ret; +} /* _write () */ + + +int +_read (int file, char *buf, int nbytes) +{ + + errno = -EAGAIN; + return -1; /* EOF */ + +} /* _read () */ + +#if 0 +int +_fstat (int file, struct stat *st) +{ + st->st_mode = S_IFCHR; + return 0; + +} /* _fstat () */ +#endif + +int +_lseek (int file, int offset, int whence) +{ + return 0; + +} /* _lseek () */ + +int +isatty (int file) +{ + return 1; + +} /* _isatty () */ + + +void +stdio_drain (void) +{ + usart1_drain(); +} |