You copied the Doc URL to your clipboard.
rt_sys.h
defines the type FILEHANDLE
.
The value of FILEHANDLE
is returned by _sys_open()
and identifies
an open file on the host system.
The default target-dependent I/O functions use semihosting. If any of these functions is redefined, then they must all be redefined. Example 11 shows you how to do this, for a device that supports writing but not reading.
FILEHANDLE _sys_open(const char *name, int openmode) { return 1; /* everything goes to the same output */ } int _sys_close(FILEHANDLE fh) { return 0; } int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) { your_device_write(buf, len); return 0; } int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) { return -1; /* not supported */ } void _ttywrch(int ch) { char c = ch; your_device_write(&c, 1); } int _sys_istty(FILEHANDLE fh) { return 0; /* buffered output */ } int _sys_seek(FILEHANDLE fh, long pos) { return -1; /* not supported */ } long _sys_flen(FILEHANDLE fh) { return -1; /* not supported */ }
If the system I/O functions are redefined, both normal character I/O and wide character I/O work. That is, you are not required to do anything extra with these functions for wide character I/O to work.