MAXREFDES63# Code Documentation  V01.00
8-Channel Digital Output MicroPLC
 All Files Functions Variables Macros Pages
retarget.c
Go to the documentation of this file.
1 
34 /*
35 * Copyright (C) 2012 Maxim Integrated Products, Inc., All Rights Reserved.
36 *
37 * Permission is hereby granted, free of charge, to any person obtaining a
38 * copy of this software and associated documentation files (the "Software"),
39 * to deal in the Software without reps_striction, including without limitation
40 * the rights to use, copy, modify, merge, publish, dips_stribute, sublicense,
41 * and/or sell copies of the Software, and to permit persons to whom the
42 * Software is furnished to do so, subject to the following conditions:
43 *
44 * The above copyright notice and this permission notice shall be included
45 * in all copies or substantial portions of the Software.
46 *
47 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
48 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50 * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
51 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
52 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53 * OTHER DEALINGS IN THE SOFTWARE.
54 *
55 * Except as contained in this notice, the name of Maxim Integrated Products
56 * shall not be used except as stated in the Maxim Integrated Products
57 * Branding Policy.
58 *
59 * The mere transfer of this software does not imply any licenses
60 * of trade secrets, proprietary technology, copyrights, patents,
61 * trademarks, maskwork rights, or any other form of intellectual
62 * property whatsoever. Maxim Integrated Products retains all ownership rights.
63 *
64 ***************************************************************************/
65 
66 #include <stdio.h>
67 #include <rt_misc.h>
68 #include "stm32f10x.h"
69 #include "stm32f10x_usart.h"
70 
71 //#pragma import(__use_no_semihosting_swi)
72 
73 
74 extern int sendchar (int c);
75 extern int getkey (void);
76 
77 
78 /*struct __FILE { int handle; };
79 FILE __stdout;
80 FILE __stdin;*/
81 
82 
83 int fputc(int c, FILE *f) {
84  uint16_t u_character;
85  u_character=c;
86  USART_SendData(USART1,u_character);
87  while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
88  return c;
89 }
90 
91 int fgetc(FILE *f) {
92  uint16_t u_character;
93  while(USART_GetFlagStatus(USART1,USART_FLAG_RXNE)==RESET);
94  u_character=USART_ReceiveData(USART1);
95 
96  USART_SendData(USART3,u_character);
97  while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
98  return (u_character);
99 }
100 
101 
102 int ferror(FILE *f) {
103  /* Your implementation of ferror */
104  return EOF;
105 }
106 
107 
108 void _ttywrch(int c) {
109  uint16_t u_character;
110  u_character=c;
111  USART_SendData(USART1,u_character);
112 }
113 
114 
115 void _sys_exit(int return_code) {
116 label: goto label; /* endless loop */
117 }