Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
70
File input and output
AVR® IAR C/C++ Compiler
Reference Guide
CUSTOMIZING FORMATTING CAPABILITIES
To customize the formatting capabilities, you need to set up a library project, see 
Building and using a customized library, page 62. Define the configuration symbols 
according to your application requirements.
File input and output
The library contains a large number of powerful functions for file I/O operations. If you 
use any of these functions you need to customize them to suit your hardware. In order 
to simplify adaptation to specific hardware, all I/O functions call a small set of primitive 
functions, each designed to accomplish one particular task; for example, __
open
 opens 
a file, and __
write
 outputs a number of characters.
Note that file I/O capability in the library is only supported by libraries with full library 
configuration, see Library configurations, page 55. In other words, file I/O is supported 
when the configuration symbol 
_ _DLIB_FILE_DESCRIPTOR
 is enabled. If not enabled, 
functions taking a 
FILE *
 argument cannot be used. 
Template code for the following I/O files are included in the product: 
The primitive functions identify I/O streams, such as an open file, with a file descriptor 
that is a unique integer. The I/O streams normally associated with 
stdin
stdout
, and 
stderr
 have the file descriptors 
0
1
, and
2
, respectively.
Note: If you link your library with I/O debugging support, C-SPY variants of the 
low-level I/O functions will be linked for interaction with C-SPY. For more 
information, see Debug support in the runtime library, page 56.
I/O function
File
Description
_ _close
 
close.c
Closes a file.
_ _lseek lseek.c
Sets the file position indicator.
_ _open open.c
Opens a file.
_ _read read.c
Reads a character buffer.
_ _write write.c
Writes a character buffer.
remove remove.c
Removes a file.
rename rename.c
Renames a file.
Table 21: Low-level I/O files