__read
In this section:
Source file
rh850\src\lib\file\read.cDeclared in
LowLevelIOInterface.h
Description
Low-level function that reads characters from stdin and from files.
C-SPY debug action
Directs stdin to the Terminal I/O window. All other files will read the associated host file.
Default implementation
None.
Example
The code in this example uses memory-mapped I/O to read from a keyboard, whose port is assumed to be located at address 0x8:
#include <stddef.h>
__no_init volatile unsigned char kbIO @ 8;
size_t __read(int handle,
unsigned char *buf,
size_t bufSize)
{
size_t nChars = 0;
/* Check for stdin
(only necessary if FILE descriptors are enabled) */
if (handle != 0)
{
return -1;
}
for (/*Empty*/; bufSize > 0; --bufSize)
{
unsigned char c = kbIO;
if (c == 0)
break;
*buf++ = c;
++nChars;
}
return nChars;
}For information about the handles associated with the streams, see Retargeting—Adapting for your target system.
For information about the @ operator, see Controlling data and function placement in memory.