]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/read.c
Rename DummyTCB_t to StaticTCB_t.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAME70_Xplained_AtmelStudio / src / ASF / common / utils / stdio / read.c
diff --git a/FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/read.c b/FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/read.c
new file mode 100644 (file)
index 0000000..5260e97
--- /dev/null
@@ -0,0 +1,167 @@
+/**\r
+ * \file\r
+ *\r
+ * \brief System-specific implementation of the \ref _read function used by\r
+ *         the standard library.\r
+ *\r
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.\r
+ *\r
+ * \asf_license_start\r
+ *\r
+ * \page License\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ *    this list of conditions and the following disclaimer.\r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ *    this list of conditions and the following disclaimer in the documentation\r
+ *    and/or other materials provided with the distribution.\r
+ *\r
+ * 3. The name of Atmel may not be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * 4. This software may only be redistributed and used in connection with an\r
+ *    Atmel microcontroller product.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED\r
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR\r
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * \asf_license_stop\r
+ *\r
+ */\r
+/*\r
+ * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>\r
+ */\r
+\r
+#include "compiler.h"\r
+\r
+/**\r
+ * \defgroup group_common_utils_stdio Standard I/O (stdio)\r
+ *\r
+ * Common standard I/O driver that implements the stdio\r
+ * read and write functions on AVR and SAM devices.\r
+ *\r
+ * \{\r
+ */\r
+\r
+extern volatile void *volatile stdio_base;\r
+void (*ptr_get)(void volatile*, char*);\r
+\r
+\r
+// IAR common implementation\r
+#if ( defined(__ICCAVR32__) || defined(__ICCAVR__) || defined(__ICCARM__) )\r
+\r
+#include <yfuns.h>\r
+\r
+_STD_BEGIN\r
+\r
+#pragma module_name = "?__read"\r
+\r
+/*! \brief Reads a number of bytes, at most \a size, into the memory area\r
+ *         pointed to by \a buffer.\r
+ *\r
+ * \param handle File handle to read from.\r
+ * \param buffer Pointer to buffer to write read bytes to.\r
+ * \param size Number of bytes to read.\r
+ *\r
+ * \return The number of bytes read, \c 0 at the end of the file, or\r
+ *         \c _LLIO_ERROR on failure.\r
+ */\r
+size_t __read(int handle, unsigned char *buffer, size_t size)\r
+{\r
+       int nChars = 0;\r
+       // This implementation only reads from stdin.\r
+       // For all other file handles, it returns failure.\r
+       if (handle != _LLIO_STDIN) {\r
+               return _LLIO_ERROR;\r
+       }\r
+       for (; size > 0; --size) {\r
+               ptr_get(stdio_base, (char*)buffer);\r
+               buffer++;\r
+               nChars++;\r
+       }\r
+       return nChars;\r
+}\r
+\r
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10\r
+ * the implementation is empty to be compatible with old IAR version.\r
+ */\r
+int __close(int handle)\r
+{\r
+       UNUSED(handle);\r
+       return 0;\r
+}\r
+\r
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10\r
+ * the implementation is empty to be compatible with old IAR version.\r
+ */\r
+int remove(const char* val)\r
+{\r
+       UNUSED(val);\r
+       return 0;\r
+}\r
+\r
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10\r
+ * the implementation is empty to be compatible with old IAR version.\r
+ */\r
+long __lseek(int handle, long val, int val2)\r
+{\r
+       UNUSED(handle);\r
+       UNUSED(val2);\r
+       return val;\r
+}\r
+\r
+_STD_END\r
+\r
+// GCC AVR32 and SAM implementation\r
+#elif (defined(__GNUC__) && !XMEGA && !MEGA) \r
+\r
+int __attribute__((weak))\r
+_read (int file, char * ptr, int len); // Remove GCC compiler warning\r
+\r
+int __attribute__((weak))\r
+_read (int file, char * ptr, int len)\r
+{\r
+       int nChars = 0;\r
+\r
+       if (file != 0) {\r
+               return -1;\r
+       }\r
+\r
+       for (; len > 0; --len) {\r
+               ptr_get(stdio_base, ptr);\r
+               ptr++;\r
+               nChars++;\r
+       }\r
+       return nChars;\r
+}\r
+\r
+// GCC AVR implementation\r
+#elif (defined(__GNUC__) && (XMEGA || MEGA) )\r
+\r
+int _read (int *f); // Remove GCC compiler warning\r
+\r
+int _read (int *f)\r
+{\r
+       char c;\r
+       ptr_get(stdio_base,&c);\r
+       return c;\r
+}\r
+#endif\r
+\r
+/**\r
+ * \}\r
+ */\r
+\r