read.c
Go to the documentation of this file.
1 
34 /*
35  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
36  */
37 
38 #include "compiler.h"
39 
49 extern volatile void *volatile stdio_base;
50 void (*ptr_get)(void volatile*, char*);
51 
52 
53 // IAR common implementation
54 #if ( defined(__ICCAVR32__) || defined(__ICCAVR__) || defined(__ICCARM__) )
55 
56 #include <yfuns.h>
57 
58 #if (__VER__ < 8010000)
59 // Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf
60 _STD_BEGIN
61 #endif
62 
63 
64 #pragma module_name = "?__read"
65 
76 size_t __read(int handle, unsigned char *buffer, size_t size)
77 {
78  int nChars = 0;
79  // This implementation only reads from stdin.
80  // For all other file handles, it returns failure.
81  if (handle != _LLIO_STDIN) {
82  return _LLIO_ERROR;
83  }
84  for (; size > 0; --size) {
85  ptr_get(stdio_base, (char*)buffer);
86  buffer++;
87  nChars++;
88  }
89  return nChars;
90 }
91 
95 int __close(int handle)
96 {
97  UNUSED(handle);
98  return 0;
99 }
100 
104 int remove(const char* val)
105 {
106  UNUSED(val);
107  return 0;
108 }
109 
113 long __lseek(int handle, long val, int val2)
114 {
115  UNUSED(handle);
116  UNUSED(val2);
117  return val;
118 }
119 
120 #if (__VER__ < 8010000)
121 // Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf
122 _STD_END
123 #endif
124 
125 // GCC AVR32 and SAM implementation
126 #elif (defined(__GNUC__) && !XMEGA && !MEGA)
127 
128 int __attribute__((weak))
129 _read (int file, char * ptr, int len); // Remove GCC compiler warning
130 
131 int __attribute__((weak))
132 _read (int file, char * ptr, int len)
133 {
134  int nChars = 0;
135 
136  if (file != 0) {
137  return -1;
138  }
139 
140  for (; len > 0; --len) {
141  ptr_get(stdio_base, ptr);
142  ptr++;
143  nChars++;
144  }
145  return nChars;
146 }
147 
148 // GCC AVR implementation
149 #elif (defined(__GNUC__) && (XMEGA || MEGA) )
150 
151 int _read (int *f); // Remove GCC compiler warning
152 
153 int _read (int *f)
154 {
155  char c;
156  ptr_get(stdio_base,&c);
157  return c;
158 }
159 #endif
160 
#define UNUSED(v)
Marking v as a unused parameter or value.
Definition: compiler.h:86
volatile void *volatile stdio_base
Definition: write.c:46
Commonly used includes, types and macros.
typedef __attribute__
USB Device LPM Descriptor structure.
Definition: d_usartDMA.c:1064
void(* ptr_get)(void volatile *, char *)
Pointer to the external low level read function.
Definition: read.c:50


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58