11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRSt<strong>and</strong>ard IO FunctionsSince st<strong>and</strong>ard file IO is not meaningful <strong>for</strong> an embedded microcontroller, much of <strong>the</strong>st<strong>and</strong>ard stdio.h content is not applicable. Never<strong>the</strong>less, some IO functions aresupported. Use #include be<strong>for</strong>e using <strong>the</strong>se functions. You will need toinitialize <strong>the</strong> output port. The lowest level of IO routines consists of <strong>the</strong> singlecharacterinput (getchar) <strong>and</strong> output (putchar) routines. You will need toimplement <strong>the</strong>se routines since <strong>the</strong>y are specific to <strong>the</strong> target device. We provideexample implementations <strong>and</strong> <strong>for</strong> most cases, you just need to copy <strong>the</strong> correctexample file to your project. See <strong>the</strong> function descriptions below. You do not need tomake modifications to <strong>the</strong> high-level st<strong>and</strong>ard IO functions such as printf,sprintf, scanf, etc.Using printf on Multiple Output DevicesIt is very simple to use printf on multiple devices. You can write your ownputchar() that writes to different devices depending on a global variable <strong>and</strong> afunction that changes this variable. Then it is just a matter of calling <strong>the</strong> device changefunction when you want to switch to use a different device. You can even implement aversion of printf that takes some sort of device number argument by using <strong>the</strong>vfprintf() function, described below.List of St<strong>and</strong>ard IO Functions int getchar(void)returns a character. You must implement this function as it is device-specific.There are example functions that use <strong>the</strong> UART registers in <strong>the</strong> directoryc:\iccv8<strong>avr</strong>\examples.<strong>avr</strong>\ with file names getchar???.c. You maymake a copy of <strong>the</strong> file that matches your target <strong>and</strong> make any modifications ifneeded <strong>and</strong> add it to your project file list. int printf(char *fmt, ..)printf prints out <strong>for</strong>matted text according to <strong>the</strong> <strong>for</strong>mat specifiers in <strong>the</strong> fmtstring. NOTE: printf is supplied in three versions, depending on your codesize <strong>and</strong> feature requirements (<strong>the</strong> more features, <strong>the</strong> higher <strong>the</strong> code size): Basic: only %c, %d, %x, %u, %p, <strong>and</strong> %s <strong>for</strong>mat specifiers without modifiersare accepted. Long: <strong>the</strong> long modifiers %ld, %lu, %lx are supported, in addition to <strong>the</strong>width <strong>and</strong> precision fields. Floating-point: all <strong>for</strong>mats, including %f <strong>for</strong> floating-point, are supported.95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!