Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
The DLIB runtime environment
67
MODIFYING THE FILE CSTARTUP.S90 
As noted earlier, you should not modify the file 
cstartup.s90
 if a customized version 
of 
_ _low_level_init
 is enough for your needs. However, if you do need to modify 
the file 
cstartup.s90
, we recommend that you follow the general procedure for 
creating a modified copy of the file and adding it to your project, see Overriding library 
modules
, page 61.
Standard streams for input and output
There are three standard communication channels (streams)—
stdin
stdout
, and 
stderr
—which are defined in 
stdio.h
. If any of these streams are used by your 
application, for example by the functions 
printf
 and 
scanf
, you need to customize the 
low-level functionality to suit your hardware.
There are primitive I/O functions, which are the fundamental functions through which 
C and C++ performs all character-based I/O. For any character-based I/O to be available, 
you must provide definitions for these functions using whatever facilities the hardware 
environment provides.
IMPLEMENTING LOW-LEVEL CHARACTER INPUT AND 
OUTPUT
To implement low-level functionality of the 
stdin
 and 
stdout
 streams, you must write 
the functions 
_ _read
 and 
_ _write
, respectively. You can find template source code for 
these functions in the 
avr\src
 directory. 
If you intend to rebuild the library, the source files are available in the template library 
project, see Building and using a customized library, page 62. Note that customizing the 
low-level routines for input and output does not require you to rebuild the library.
Note: If you write your own variants of 
_ _read
 or 
_ _write
, special considerations 
for the C-SPY runtime interface are needed, seC-SPY Debugger runtime interface
page 76.
Example of using __write and __read
The code in the following examples use memory-mapped I/O to write to an LCD 
display:
_ _no_init volatile unsigned char LCD_IO @ address;
size_t _ _write(int Handle, const unsigned char * Buf,
               size_t Bufsize)