11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

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

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

The DLIB runtime environmentExample of using __write and __readThe code in the following examples use memory-mapped I/O to write to an LCDdisplay:__no_init volatile unsigned char LCD_IO @ address;size_t __write(int Handle, const unsigned char * Buf,size_t Bufsize){size_t nChars = 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){LCD_IO = * Buf++;++nChars;}return nChars;}The code in the following example uses memory-mapped I/O to read from a keyboard:__no_init volatile unsigned char KB_IO @ 0xD2;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 = KB_IO;if (c == 0)break;*Buf++ = c;++nChars;}return nChars;}Part 1. Using the compiler61

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

Saved successfully!

Ooh no, something went wrong!