aboutsummaryrefslogtreecommitdiffstats
path: root/sysmoOCTSIM/stdio_redirect
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-02-24 21:15:39 +0100
committerKévin Redon <kredon@sysmocom.de>2019-02-27 13:17:17 +0000
commit361ed2072b2a0bef18f9f740ebc4793d997adf60 (patch)
treeb1f79dce8ec44b78360316a51fe07e3519e9f5a8 /sysmoOCTSIM/stdio_redirect
parentd0903f7e517425f519b5fa680fbb068cbe5fc38b (diff)
Switch SERCOM7 (Debug UART) to sync mode + add STDIO
this will allow us to do printf() Change-Id: Ibf4ba961d4bbf8d787558f38f3d557422587aad3
Diffstat (limited to 'sysmoOCTSIM/stdio_redirect')
-rw-r--r--sysmoOCTSIM/stdio_redirect/gcc/read.c53
-rw-r--r--sysmoOCTSIM/stdio_redirect/gcc/write.c53
-rw-r--r--sysmoOCTSIM/stdio_redirect/iar/read.c114
-rw-r--r--sysmoOCTSIM/stdio_redirect/iar/write.c94
-rw-r--r--sysmoOCTSIM/stdio_redirect/keil/Retarget.c107
-rw-r--r--sysmoOCTSIM/stdio_redirect/stdio_io.c74
-rw-r--r--sysmoOCTSIM/stdio_redirect/stdio_io.h81
7 files changed, 576 insertions, 0 deletions
diff --git a/sysmoOCTSIM/stdio_redirect/gcc/read.c b/sysmoOCTSIM/stdio_redirect/gcc/read.c
new file mode 100644
index 0000000..90e4618
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/gcc/read.c
@@ -0,0 +1,53 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio_io.h>
+#include <stdio.h>
+
+int __attribute__((weak)) _read(int file, char *ptr, int len); /* Remove GCC compiler warning */
+
+int __attribute__((weak)) _read(int file, char *ptr, int len)
+{
+ int n = 0;
+
+ if (file != 0) {
+ return -1;
+ }
+
+ n = stdio_io_read((uint8_t *)ptr, len);
+ if (n < 0) {
+ return -1;
+ }
+
+ return n;
+}
diff --git a/sysmoOCTSIM/stdio_redirect/gcc/write.c b/sysmoOCTSIM/stdio_redirect/gcc/write.c
new file mode 100644
index 0000000..44fa815
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/gcc/write.c
@@ -0,0 +1,53 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio_io.h>
+#include <stdio.h>
+
+int __attribute__((weak)) _write(int file, char *ptr, int len); /* Remove GCC compiler warning */
+
+int __attribute__((weak)) _write(int file, char *ptr, int len)
+{
+ int n = 0;
+
+ if ((file != 1) && (file != 2) && (file != 3)) {
+ return -1;
+ }
+
+ n = stdio_io_write((const uint8_t *)ptr, len);
+ if (n < 0) {
+ return -1;
+ }
+
+ return n;
+}
diff --git a/sysmoOCTSIM/stdio_redirect/iar/read.c b/sysmoOCTSIM/stdio_redirect/iar/read.c
new file mode 100644
index 0000000..df192cb
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/iar/read.c
@@ -0,0 +1,114 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio_io.h>
+#include <stdio.h>
+
+#ifndef _UNIT_TEST_
+#include <yfuns.h>
+#else
+#define _STD_BEGIN
+#define _STD_END
+#define _LLIO_ERROR ((size_t)-1) /* For __read and __write. */
+#define _LLIO_STDIN 0
+#define _LLIO_STDOUT 1
+#define _LLIO_STDERR 2
+#endif
+
+#if (__VER__ < 8010000)
+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */
+_STD_BEGIN
+#endif
+
+#pragma module_name = "?__read"
+
+/*! \brief Reads a number of bytes, at most \a size, into the memory area
+ * pointed to by \a buffer.
+ *
+ * \param handle File handle to read from.
+ * \param buffer Pointer to buffer to write read bytes to.
+ * \param size Number of bytes to read.
+ *
+ * \return The number of bytes read, \c 0 at the end of the file, or
+ * \c _LLIO_ERROR on failure.
+ */
+size_t __read(int handle, unsigned char *buffer, size_t size)
+{
+ int n = 0;
+ /* This implementation only reads from stdin.
+ * For all other file handles, it returns failure. */
+ if (handle != _LLIO_STDIN) {
+ return _LLIO_ERROR;
+ }
+
+ n = stdio_io_read((uint8_t *)buffer, size);
+ if (n < 0) {
+ return _LLIO_ERROR;
+ }
+ return n;
+}
+
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10
+ * the implementation is empty to be compatible with old IAR version.
+ */
+int __close(int handle)
+{
+ (void)(handle);
+ return 0;
+}
+
+#ifndef __GNUC__
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10
+ * the implementation is empty to be compatible with old IAR version.
+ */
+int remove(const char *val)
+{
+ (void)(val);
+ return 0;
+}
+#endif
+
+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10
+ * the implementation is empty to be compatible with old IAR version.
+ */
+long __lseek(int handle, long val, int val2)
+{
+ (void)(handle);
+ (void)(val2);
+ return val;
+}
+
+#if (__VER__ < 8010000)
+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */
+_STD_END
+#endif
diff --git a/sysmoOCTSIM/stdio_redirect/iar/write.c b/sysmoOCTSIM/stdio_redirect/iar/write.c
new file mode 100644
index 0000000..7bc8f78
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/iar/write.c
@@ -0,0 +1,94 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio_io.h>
+#include <stdio.h>
+
+#ifndef _UNIT_TEST_
+#include <yfuns.h>
+#else
+#define _STD_BEGIN
+#define _STD_END
+#define _LLIO_ERROR ((size_t)-1) /* For __read and __write. */
+#define _LLIO_STDIN 0
+#define _LLIO_STDOUT 1
+#define _LLIO_STDERR 2
+#endif
+
+#if (__VER__ < 8010000)
+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */
+_STD_BEGIN
+#endif
+
+#pragma module_name = "?__write"
+
+/*! \brief Writes a number of bytes, at most \a size, from the memory area
+ * pointed to by \a buffer.
+ *
+ * If \a buffer is zero then \ref __write performs flushing of internal buffers,
+ * if any. In this case, \a handle can be \c -1 to indicate that all handles
+ * should be flushed.
+ *
+ * \param handle File handle to write to.
+ * \param buffer Pointer to buffer to read bytes to write from.
+ * \param size Number of bytes to write.
+ *
+ * \return The number of bytes written, or \c _LLIO_ERROR on failure.
+ */
+size_t __write(int handle, const unsigned char *buffer, size_t size)
+{
+ int n = 0;
+
+ if (buffer == 0) {
+ /* This means that we should flush internal buffers. */
+ return 0;
+ }
+
+ /* This implementation only writes to stdout and stderr.
+ * For all other file handles, it returns failure. */
+ if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR) {
+ return _LLIO_ERROR;
+ }
+
+ n = stdio_io_write((const uint8_t *)buffer, size);
+ if (n < 0) {
+ return _LLIO_ERROR;
+ }
+
+ return n;
+}
+
+#if (__VER__ < 8010000)
+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */
+_STD_END
+#endif
diff --git a/sysmoOCTSIM/stdio_redirect/keil/Retarget.c b/sysmoOCTSIM/stdio_redirect/keil/Retarget.c
new file mode 100644
index 0000000..205e7e5
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/keil/Retarget.c
@@ -0,0 +1,107 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio.h>
+
+#ifdef _UNIT_TEST_
+#undef fputc
+#undef fgetc
+#undef ferror
+#define fputc ut_fputc
+#define fgetc ut_fgetc
+#define ferror ut_ferror
+#endif
+
+#include <stdio_io.h>
+
+/* Disable semihosting */
+#if defined(__GNUC__) && (__ARMCOMPILER_VERSION > 6000000) /* Keil MDK with ARM Compiler 6 */
+__asm(".global __use_no_semihosting\n\t");
+#else
+#pragma import(__use_no_semihosting_swi)
+#endif
+
+#ifndef __GNUC__
+struct __FILE {
+ int handle;
+};
+#endif
+FILE __stdout;
+FILE __stdin;
+FILE __stderr;
+
+int fputc(int ch, FILE *f)
+{
+ if ((f == stdout) || (f == stderr)) {
+ uint8_t tmp = (uint8_t)ch;
+ if (stdio_io_write(&tmp, 1) < 0) {
+ return EOF;
+ }
+ return ch;
+ } else {
+ return EOF;
+ }
+}
+
+int fgetc(FILE *f)
+{
+ if (f == stdin) {
+ uint8_t tmp = 0;
+ if (stdio_io_read(&tmp, 1) < 0) {
+ return EOF;
+ }
+ return tmp;
+ } else {
+ return EOF;
+ }
+}
+
+void _ttywrch(int ch)
+{
+ uint8_t tmp = (uint8_t)ch;
+ stdio_io_write(&tmp, 1);
+}
+
+int ferror(FILE *f)
+{
+ (void)f;
+ /* Your implementation of ferror */
+ return EOF;
+}
+
+void _sys_exit(int return_code)
+{
+ (void)return_code;
+ while (1) {
+ }; /* endless loop */
+}
diff --git a/sysmoOCTSIM/stdio_redirect/stdio_io.c b/sysmoOCTSIM/stdio_redirect/stdio_io.c
new file mode 100644
index 0000000..7659f3d
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/stdio_io.c
@@ -0,0 +1,74 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection terminal
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include <stdio.h>
+#include <stdio_io.h>
+
+/** IO descriptor for STDIO access. */
+static struct io_descriptor *stdio_io = NULL;
+
+void stdio_io_init(struct io_descriptor *io)
+{
+#if defined(__GNUC__)
+ /* Specify that stdout and stdin should not be buffered. */
+ setbuf(stdout, NULL);
+ setbuf(stdin, NULL);
+ /* Note: Already the case in IAR's Normal DLIB default configuration
+ * and AVR GCC library:
+ * - printf() emits one character at a time.
+ * - getchar() requests only 1 byte to exit.
+ */
+#endif
+ stdio_io = io;
+}
+
+void stdio_io_set_io(struct io_descriptor *io)
+{
+ stdio_io = io;
+}
+
+int32_t stdio_io_read(uint8_t *buf, const int32_t len)
+{
+ if (stdio_io == NULL) {
+ return 0;
+ }
+ return io_read(stdio_io, buf, len);
+}
+
+int32_t stdio_io_write(const uint8_t *buf, const int32_t len)
+{
+ if (stdio_io == NULL) {
+ return 0;
+ }
+ return io_write(stdio_io, buf, len);
+}
diff --git a/sysmoOCTSIM/stdio_redirect/stdio_io.h b/sysmoOCTSIM/stdio_redirect/stdio_io.h
new file mode 100644
index 0000000..973adad
--- /dev/null
+++ b/sysmoOCTSIM/stdio_redirect/stdio_io.h
@@ -0,0 +1,81 @@
+/**
+ * \file
+ *
+ * \brief STDIO redirection terminal
+ *
+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef _STDIO_IO_H_INCLUDED
+#define _STDIO_IO_H_INCLUDED
+
+#include <hal_io.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * \brief Initialize STDIO access
+ * \param[in] io Pointer to IO descriptor,
+ * NULL to discard R/W without any error.
+ */
+void stdio_io_init(struct io_descriptor *io);
+
+/**
+ * \brief Change IO descriptor for terminal to R/W data
+ * \param[in] io Pointer to IO descriptor,
+ * NULL to discard R/W without any error.
+ */
+void stdio_io_set_io(struct io_descriptor *io);
+
+/**
+ * \brief Read through specified terminal
+ * \param[out] buf Pointer to buffer to place read data
+ * \param[in] len Data length in number of bytes
+ * \return status
+ * \retval >=0 number of bytes read
+ * \retval <0 error
+ */
+int32_t stdio_io_read(uint8_t *buf, const int32_t len);
+
+/**
+ * \brief Write through specified terminal
+ * \param[in] buf Pointer to buffer to place data to write
+ * \param[in] len Data length in number of bytes
+ * \return status
+ * \retval >=0 number of bytes read
+ * \retval <0 error
+ */
+int32_t stdio_io_write(const uint8_t *buf, const int32_t len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _STDIO_IO_H_INCLUDED */