]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/stdio_serial/stdio_serial.h
Rename DummyTCB_t to StaticTCB_t.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAME70_Xplained_AtmelStudio / src / ASF / common / utils / stdio / stdio_serial / stdio_serial.h
diff --git a/FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/stdio_serial/stdio_serial.h b/FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/common/utils/stdio/stdio_serial/stdio_serial.h
new file mode 100644 (file)
index 0000000..556821c
--- /dev/null
@@ -0,0 +1,129 @@
+/**\r
+ *\r
+ * \file\r
+ *\r
+ * \brief Common Standard I/O Serial Management.\r
+ *\r
+ * This file defines a useful set of functions for the Stdio Serial interface on AVR\r
+ * and SAM devices.\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
+\r
+#ifndef _STDIO_SERIAL_H_\r
+#define _STDIO_SERIAL_H_\r
+\r
+/**\r
+ * \defgroup group_common_utils_stdio_stdio_serial Standard serial I/O (stdio)\r
+ * \ingroup group_common_utils_stdio\r
+ *\r
+ * Common standard serial I/O management driver that\r
+ * implements a stdio serial interface on AVR and SAM devices.\r
+ *\r
+ * \{\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "compiler.h"\r
+#ifndef SAMD20\r
+# include "sysclk.h"\r
+#endif\r
+#include "serial.h"\r
+\r
+#if (XMEGA || MEGA_RF) && defined(__GNUC__)\r
+       extern int _write (char c, int *f);\r
+       extern int _read (int *f);\r
+#endif\r
+\r
+\r
+//! Pointer to the base of the USART module instance to use for stdio.\r
+extern volatile void *volatile stdio_base;\r
+//! Pointer to the external low level write function.\r
+extern int (*ptr_put)(void volatile*, char);\r
+\r
+//! Pointer to the external low level read function.\r
+extern void (*ptr_get)(void volatile*, char*);\r
+\r
+/*! \brief Initializes the stdio in Serial Mode.\r
+ *\r
+ * \param usart       Base address of the USART instance.\r
+ * \param opt         Options needed to set up RS232 communication (see \ref usart_options_t).\r
+ *\r
+ */\r
+static inline void stdio_serial_init(volatile void *usart, const usart_serial_options_t *opt)\r
+{\r
+       stdio_base = (void *)usart;\r
+       ptr_put = (int (*)(void volatile*,char))&usart_serial_putchar;\r
+       ptr_get = (void (*)(void volatile*,char*))&usart_serial_getchar;\r
+# if (XMEGA || MEGA_RF)\r
+       usart_serial_init((USART_t *)usart,opt);\r
+# elif UC3\r
+       usart_serial_init(usart,(usart_serial_options_t *)opt);\r
+# elif SAM\r
+       usart_serial_init((Usart *)usart,(usart_serial_options_t *)opt);\r
+# else\r
+#  error Unsupported chip type\r
+# endif\r
+\r
+# if defined(__GNUC__)\r
+#  if (XMEGA || MEGA_RF)\r
+       // For AVR GCC libc print redirection uses fdevopen.\r
+       fdevopen((int (*)(char, FILE*))(_write),(int (*)(FILE*))(_read));\r
+#  endif\r
+#  if UC3 || SAM\r
+       // For AVR32 and SAM GCC\r
+       // Specify that stdout and stdin should not be buffered.\r
+       setbuf(stdout, NULL);\r
+       setbuf(stdin, NULL);\r
+       // Note: Already the case in IAR's Normal DLIB default configuration\r
+       // and AVR GCC library:\r
+       // - printf() emits one character at a time.\r
+       // - getchar() requests only 1 byte to exit.\r
+#  endif\r
+# endif\r
+}\r
+\r
+/**\r
+ * \}\r
+ */\r
+\r
+#endif  // _STDIO_SERIAL_H_\r