__write
In this section:
Source file
rx\src\lib\dlib\file\write.c
Declared in
LowLevelIOInterface.h
Description
Low-level function that writes to stdout, stderr, or a file.
C-SPY debug action
Directs stdout and stderr to the Terminal I/O window. All other files will write to the associated host file.
Default implementation
None.
Example
The code in this example uses memory-mapped I/O to write to an LCD display, whose port is assumed to be located at address 0x8:
#include <stddef.h>
__no_init volatile unsigned char lcdIO @ 8;
size_t __write(int handle,
const unsigned char *buf,
size_t bufSize)
{
size_t nChars = 0;
/* Check for the command to flush all handles */
if (handle == -1)
{
return 0;
}
/* Check for stdout and stderr
(only necessary if FILE descriptors are enabled.) */
if (handle != 1 && handle != 2)
{
return -1;
}
for (/* Empty */; bufSize > 0; --bufSize)
{
lcdIO = *buf;
++buf;
++nChars;
}
return nChars;
}For information about the handles associated with the streams, see Retargeting—Adapting for your target system.