diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-11-15 08:52:17 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-11-15 08:52:17 +0000 |
commit | 84cf9ce9ffa3d538b367f74c8206b8ef894d466f (patch) | |
tree | b3931fee4361ec810cae4492fd4cca42bae6b037 /os | |
parent | 55252f65b2a444692ff1b2673b32ec1cf2b205c0 (diff) | |
download | ChibiOS-84cf9ce9ffa3d538b367f74c8206b8ef894d466f.tar.gz ChibiOS-84cf9ce9ffa3d538b367f74c8206b8ef894d466f.tar.bz2 ChibiOS-84cf9ce9ffa3d538b367f74c8206b8ef894d466f.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1299 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/various/syscalls.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/os/various/syscalls.c b/os/various/syscalls.c index 258d9c9d6..e635b1388 100644 --- a/os/various/syscalls.c +++ b/os/various/syscalls.c @@ -63,18 +63,31 @@ #include <sys/types.h> #include <ch.h> +#if defined(STDOUT_SD) || defined(STDIN_SD) +#include <serial.h> +#endif /***************************************************************************/ int _read_r(struct _reent *r, int file, char * ptr, int len) { (void)r; +#if defined(STDIN_SD) + if (!len || (file != 0)) { + errno = EINVAL; + return -1; + } + *ptr++ = chIOGet(&STDOUT_SD); + if (--len > 0) + len = chIORead(&STDOUT_SD, (uint8_t *)ptr, (size_t)len); + return len; +#else (void)file; (void)ptr; (void)len; - errno = EINVAL; return -1; +#endif } /***************************************************************************/ @@ -93,10 +106,20 @@ int _lseek_r(struct _reent *r, int file, int ptr, int dir) int _write_r(struct _reent *r, int file, char * ptr, int len) { + int n; + (void)r; (void)file; (void)ptr; - +#if defined(STDOUT_SD) + if (file != 1) { + errno = EINVAL; + return -1; + } + n = len; + while (n--) + chIOPut(&STDOUT_SD, *ptr++); +#endif return len; } |