These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
EMAC/uIP/common/Retarget.c@0:bf7b9fba3924, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 05:38:56 2011 +0000
- Revision:
- 0:bf7b9fba3924
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:bf7b9fba3924 | 1 | /******************************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 2 | /* RETARGET.C: 'Retarget' layer for target-dependent low level functions */ |
frank26080115 | 0:bf7b9fba3924 | 3 | /******************************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 4 | /* This file is part of the uVision/ARM development tools. */ |
frank26080115 | 0:bf7b9fba3924 | 5 | /* Copyright (c) 2005-2007 Keil Software. All rights reserved. */ |
frank26080115 | 0:bf7b9fba3924 | 6 | /* This software may only be used under the terms of a valid, current, */ |
frank26080115 | 0:bf7b9fba3924 | 7 | /* end user licence from KEIL for a compatible version of KEIL software */ |
frank26080115 | 0:bf7b9fba3924 | 8 | /* development tools. Nothing else gives you the right to use this software. */ |
frank26080115 | 0:bf7b9fba3924 | 9 | /******************************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 10 | |
frank26080115 | 0:bf7b9fba3924 | 11 | #include <stdio.h> |
frank26080115 | 0:bf7b9fba3924 | 12 | #include <rt_misc.h> |
frank26080115 | 0:bf7b9fba3924 | 13 | |
frank26080115 | 0:bf7b9fba3924 | 14 | #pragma import(__use_no_semihosting_swi) |
frank26080115 | 0:bf7b9fba3924 | 15 | |
frank26080115 | 0:bf7b9fba3924 | 16 | // implementation depends on the microcontroller hardware |
frank26080115 | 0:bf7b9fba3924 | 17 | extern unsigned char sendchar(unsigned char ch); /* in serial.c */ |
frank26080115 | 0:bf7b9fba3924 | 18 | extern unsigned char getkey(void); |
frank26080115 | 0:bf7b9fba3924 | 19 | |
frank26080115 | 0:bf7b9fba3924 | 20 | |
frank26080115 | 0:bf7b9fba3924 | 21 | struct __FILE { int handle; /* Add whatever you need here */ }; |
frank26080115 | 0:bf7b9fba3924 | 22 | FILE __stdout; |
frank26080115 | 0:bf7b9fba3924 | 23 | FILE __stdin; |
frank26080115 | 0:bf7b9fba3924 | 24 | |
frank26080115 | 0:bf7b9fba3924 | 25 | int fputc(int ch, FILE *f) { |
frank26080115 | 0:bf7b9fba3924 | 26 | return (sendchar(ch)); |
frank26080115 | 0:bf7b9fba3924 | 27 | } |
frank26080115 | 0:bf7b9fba3924 | 28 | |
frank26080115 | 0:bf7b9fba3924 | 29 | // simplified fgetc version that only redirects STDIN |
frank26080115 | 0:bf7b9fba3924 | 30 | #if 1 |
frank26080115 | 0:bf7b9fba3924 | 31 | int fgetc(FILE * fp) |
frank26080115 | 0:bf7b9fba3924 | 32 | { |
frank26080115 | 0:bf7b9fba3924 | 33 | // redirect STDIN |
frank26080115 | 0:bf7b9fba3924 | 34 | return(getkey()); |
frank26080115 | 0:bf7b9fba3924 | 35 | } |
frank26080115 | 0:bf7b9fba3924 | 36 | #else // echo a char |
frank26080115 | 0:bf7b9fba3924 | 37 | int fgetc(FILE * fp) |
frank26080115 | 0:bf7b9fba3924 | 38 | { |
frank26080115 | 0:bf7b9fba3924 | 39 | return(sendchar(getkey())); |
frank26080115 | 0:bf7b9fba3924 | 40 | } |
frank26080115 | 0:bf7b9fba3924 | 41 | #endif |
frank26080115 | 0:bf7b9fba3924 | 42 | |
frank26080115 | 0:bf7b9fba3924 | 43 | |
frank26080115 | 0:bf7b9fba3924 | 44 | int ferror(FILE *f) { |
frank26080115 | 0:bf7b9fba3924 | 45 | /* Your implementation of ferror */ |
frank26080115 | 0:bf7b9fba3924 | 46 | return EOF; |
frank26080115 | 0:bf7b9fba3924 | 47 | } |
frank26080115 | 0:bf7b9fba3924 | 48 | |
frank26080115 | 0:bf7b9fba3924 | 49 | |
frank26080115 | 0:bf7b9fba3924 | 50 | void _ttywrch(int ch) { |
frank26080115 | 0:bf7b9fba3924 | 51 | sendchar(ch); |
frank26080115 | 0:bf7b9fba3924 | 52 | } |
frank26080115 | 0:bf7b9fba3924 | 53 | |
frank26080115 | 0:bf7b9fba3924 | 54 | |
frank26080115 | 0:bf7b9fba3924 | 55 | void _sys_exit(int return_code) { |
frank26080115 | 0:bf7b9fba3924 | 56 | label: goto label; /* endless loop */ |
frank26080115 | 0:bf7b9fba3924 | 57 | } |