<p>Kévin Redon <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13035">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kévin Redon: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Switch SERCOM7 (Debug UART) to sync mode + add STDIO<br><br>this will allow us to do printf()<br><br>Change-Id: Ibf4ba961d4bbf8d787558f38f3d557422587aad3<br>---<br>M sysmoOCTSIM/AtmelStart.gpdsc<br>M sysmoOCTSIM/atmel_start.c<br>M sysmoOCTSIM/atmel_start.h<br>M sysmoOCTSIM/atmel_start_config.atstart<br>A sysmoOCTSIM/config/stdio_redirect_config.h<br>A sysmoOCTSIM/documentation/stdio.rst<br>M sysmoOCTSIM/driver_init.c<br>M sysmoOCTSIM/driver_init.h<br>M sysmoOCTSIM/examples/driver_examples.c<br>M sysmoOCTSIM/gcc/Makefile<br>M sysmoOCTSIM/hpl/sercom/hpl_sercom.c<br>M sysmoOCTSIM/main.c<br>A sysmoOCTSIM/stdio_redirect/gcc/read.c<br>A sysmoOCTSIM/stdio_redirect/gcc/write.c<br>A sysmoOCTSIM/stdio_redirect/iar/read.c<br>A sysmoOCTSIM/stdio_redirect/iar/write.c<br>A sysmoOCTSIM/stdio_redirect/keil/Retarget.c<br>A sysmoOCTSIM/stdio_redirect/stdio_io.c<br>A sysmoOCTSIM/stdio_redirect/stdio_io.h<br>A sysmoOCTSIM/stdio_start.c<br>A sysmoOCTSIM/stdio_start.h<br>21 files changed, 769 insertions(+), 131 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/sysmoOCTSIM/AtmelStart.gpdsc b/sysmoOCTSIM/AtmelStart.gpdsc</span><br><span>index 6546fb5..5d35944 100644</span><br><span>--- a/sysmoOCTSIM/AtmelStart.gpdsc</span><br><span>+++ b/sysmoOCTSIM/AtmelStart.gpdsc</span><br><span>@@ -36,6 +36,14 @@</span><br><span>       <require Dname="ATSAME54N19A"/></span><br><span>       <accept Tcompiler="GCC"/></span><br><span>     </condition></span><br><span style="color: hsl(120, 100%, 40%);">+    <condition id="IAR"></span><br><span style="color: hsl(120, 100%, 40%);">+      <require Dname="ATSAME54N19A"/></span><br><span style="color: hsl(120, 100%, 40%);">+      <accept Tcompiler="IAR"/></span><br><span style="color: hsl(120, 100%, 40%);">+    </condition></span><br><span style="color: hsl(120, 100%, 40%);">+    <condition id="ARMCC"></span><br><span style="color: hsl(120, 100%, 40%);">+      <require Dname="ATSAME54N19A"/></span><br><span style="color: hsl(120, 100%, 40%);">+      <accept Tcompiler="ARMCC"/></span><br><span style="color: hsl(120, 100%, 40%);">+    </condition></span><br><span>   </conditions></span><br><span>   <components generator="AtmelStart"></span><br><span>     <component Cclass="AtmelStart" Cgroup="Framework" Cversion="1.0.0" condition="CMSIS Device Startup"></span><br><span>@@ -43,6 +51,7 @@</span><br><span>       <RTE_Components_h>#define ATMEL_START</RTE_Components_h></span><br><span>       <files></span><br><span>         <file category="doc" condition="ARMCC, GCC, IAR" name="hal/documentation/usart_async.rst"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="doc" condition="ARMCC, GCC, IAR" name="hal/documentation/usart_sync.rst"/></span><br><span>         <file category="doc" condition="ARMCC, GCC, IAR" name="hal/documentation/usb_device_async.rst"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hal_atomic.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hal_cache.h"/></span><br><span>@@ -155,6 +164,14 @@</span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="usb/usb_includes.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="usb/usb_protocol.c"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="usb/usb_protocol.h"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="doc" condition="ARMCC, GCC, IAR" name="documentation/stdio.rst"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="GCC" name="stdio_redirect/gcc/read.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="GCC" name="stdio_redirect/gcc/write.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="IAR" name="stdio_redirect/iar/read.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="IAR" name="stdio_redirect/iar/write.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="ARMCC" name="stdio_redirect/keil/Retarget.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="ARMCC, GCC, IAR" name="stdio_redirect/stdio_io.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="header" condition="ARMCC, GCC, IAR" name="stdio_redirect/stdio_io.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="main.c"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="driver_init.c"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="driver_init.h"/></span><br><span>@@ -162,6 +179,7 @@</span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="examples/driver_examples.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="examples/driver_examples.c"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hal_usart_async.h"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hal_usart_sync.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hpl_missing_features.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hpl_reset.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hpl_spi_m_async.h"/></span><br><span>@@ -172,6 +190,7 @@</span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hpl_usart_async.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/include/hpl_usart_sync.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="hal/src/hal_usart_async.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="ARMCC, GCC, IAR" name="hal/src/hal_usart_sync.c"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="hal/utils/include/parts.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="hpl/cmcc/hpl_cmcc.c"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="hpl/core/hpl_core_m4.c"/></span><br><span>@@ -191,6 +210,8 @@</span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="hpl/usb/hpl_usb.c"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="usb_start.c"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="usb_start.h"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="source" condition="ARMCC, GCC, IAR" name="stdio_start.c"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="header" condition="ARMCC, GCC, IAR" name="stdio_start.h"/></span><br><span>         <file category="header" condition="ARMCC, GCC, IAR" name="atmel_start.h"/></span><br><span>         <file category="source" condition="ARMCC, GCC, IAR" name="atmel_start.c"/></span><br><span>         <file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/hpl_cmcc_config.h"/></span><br><span>@@ -204,6 +225,7 @@</span><br><span>         <file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/hpl_usb_config.h"/></span><br><span>         <file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/peripheral_clk_config.h"/></span><br><span>         <file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/usbd_config.h"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file attr="config" category="header" condition="ARMCC, GCC, IAR" name="config/stdio_redirect_config.h"/></span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name=""/></span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name="config"/></span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name="examples"/></span><br><span>@@ -229,6 +251,9 @@</span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name="usb/class/cdc/device"/></span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name="usb/device"/></span><br><span>         <file category="include" condition="ARMCC, GCC, IAR" name=""/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="include" condition="ARMCC, GCC, IAR" name="config"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="include" condition="ARMCC, GCC, IAR" name="stdio_redirect"/></span><br><span style="color: hsl(120, 100%, 40%);">+        <file category="include" condition="ARMCC, GCC, IAR" name=""/></span><br><span>       </files></span><br><span>     </component></span><br><span>   </components></span><br><span>diff --git a/sysmoOCTSIM/atmel_start.c b/sysmoOCTSIM/atmel_start.c</span><br><span>index 9a5f36c..fc6016a 100644</span><br><span>--- a/sysmoOCTSIM/atmel_start.c</span><br><span>+++ b/sysmoOCTSIM/atmel_start.c</span><br><span>@@ -7,4 +7,5 @@</span><br><span> {</span><br><span>   system_init();</span><br><span>       usb_init();</span><br><span style="color: hsl(120, 100%, 40%);">+   stdio_redirect_init();</span><br><span> }</span><br><span>diff --git a/sysmoOCTSIM/atmel_start.h b/sysmoOCTSIM/atmel_start.h</span><br><span>index 953f947..92afa47 100644</span><br><span>--- a/sysmoOCTSIM/atmel_start.h</span><br><span>+++ b/sysmoOCTSIM/atmel_start.h</span><br><span>@@ -7,6 +7,7 @@</span><br><span> </span><br><span> #include "driver_init.h"</span><br><span> #include "usb_start.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "stdio_start.h"</span><br><span> </span><br><span> /**</span><br><span>  * Initializes MCU, drivers and middleware in the project</span><br><span>diff --git a/sysmoOCTSIM/atmel_start_config.atstart b/sysmoOCTSIM/atmel_start_config.atstart</span><br><span>index a301385..1bbad8f 100644</span><br><span>--- a/sysmoOCTSIM/atmel_start_config.atstart</span><br><span>+++ b/sysmoOCTSIM/atmel_start_config.atstart</span><br><span>@@ -82,6 +82,14 @@</span><br><span>     dependencies:</span><br><span>       USB Device Stack Core Instance: USB_DEVICE_STACK_CORE_INSTANCE</span><br><span>       USB Class CDC: USB_CLASS_CDC</span><br><span style="color: hsl(120, 100%, 40%);">+  STDIO_REDIRECT_0:</span><br><span style="color: hsl(120, 100%, 40%);">+    user_label: STDIO_REDIRECT_0</span><br><span style="color: hsl(120, 100%, 40%);">+    configuration: {}</span><br><span style="color: hsl(120, 100%, 40%);">+    definition: Atmel:STDIO_redirect:0.0.1::STDIO_Redirect</span><br><span style="color: hsl(120, 100%, 40%);">+    functionality: STDIO_Redirect</span><br><span style="color: hsl(120, 100%, 40%);">+    api: STDIO:Redirect:IO</span><br><span style="color: hsl(120, 100%, 40%);">+    dependencies:</span><br><span style="color: hsl(120, 100%, 40%);">+      Target IO: UART_debug</span><br><span> drivers:</span><br><span>   CMCC:</span><br><span>     user_label: CMCC</span><br><span>@@ -1276,9 +1284,9 @@</span><br><span>           slow_gclk_selection: Generic clock generator 3</span><br><span>   UART_debug:</span><br><span>     user_label: UART_debug</span><br><span style="color: hsl(0, 100%, 40%);">-    definition: Atmel:SAME54_Drivers:0.0.1::SAME54N19A-AF::SERCOM7::driver_config_definition::UART::HAL:Driver:USART.Async</span><br><span style="color: hsl(120, 100%, 40%);">+    definition: Atmel:SAME54_Drivers:0.0.1::SAME54N19A-AF::SERCOM7::driver_config_definition::UART::HAL:Driver:USART.Sync</span><br><span>     functionality: USART</span><br><span style="color: hsl(0, 100%, 40%);">-    api: HAL:Driver:USART_Async</span><br><span style="color: hsl(120, 100%, 40%);">+    api: HAL:Driver:USART_Sync</span><br><span>     configuration:</span><br><span>       usart_advanced: false</span><br><span>       usart_arch_clock_mode: USART with internal clock</span><br><span>diff --git a/sysmoOCTSIM/config/stdio_redirect_config.h b/sysmoOCTSIM/config/stdio_redirect_config.h</span><br><span>new file mode 100644</span><br><span>index 0000000..3515c0c</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/config/stdio_redirect_config.h</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* Auto-generated config file stdio_redirect_config.h */</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef STDIO_REDIRECT_CONFIG_H</span><br><span style="color: hsl(120, 100%, 40%);">+#define STDIO_REDIRECT_CONFIG_H</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <<< Use Configuration Wizard in Context Menu >>></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <<< end of configuration section >>></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif // STDIO_REDIRECT_CONFIG_H</span><br><span>diff --git a/sysmoOCTSIM/documentation/stdio.rst b/sysmoOCTSIM/documentation/stdio.rst</span><br><span>new file mode 100644</span><br><span>index 0000000..2864b49</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/documentation/stdio.rst</span><br><span>@@ -0,0 +1,34 @@</span><br><span style="color: hsl(120, 100%, 40%);">+STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+=================</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The STDIO redirection provides means to redirect standard input/output to HAL</span><br><span style="color: hsl(120, 100%, 40%);">+IO.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+On initialization, the HAL IO descriptor is assigned so that all input and</span><br><span style="color: hsl(120, 100%, 40%);">+output is redirected to access it. The IO descriptor can also be changed</span><br><span style="color: hsl(120, 100%, 40%);">+through stdio_io_set_io(). All stdin or stdout access is redirected to the</span><br><span style="color: hsl(120, 100%, 40%);">+IO descriptor. When the IO descriptor is set to NULL, all input and output </span><br><span style="color: hsl(120, 100%, 40%);">+are discarded.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For GCC redirection, the stdout and stdin buffer are turned off, the</span><br><span style="color: hsl(120, 100%, 40%);">+standard _read() and _write() are overridden.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For IAR redirection, the __read() and __write() are overridden.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For Keil redirection, the Retarget.c are modified to override fputc(), fgetc(),</span><br><span style="color: hsl(120, 100%, 40%);">+etc.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Features</span><br><span style="color: hsl(120, 100%, 40%);">+--------</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* Standard input/output redirection (e.g., printf to EDBG COM port)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Dependencies</span><br><span style="color: hsl(120, 100%, 40%);">+------------</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* HAL IO driver</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Limitations</span><br><span style="color: hsl(120, 100%, 40%);">+-----------</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* IO read/write operation should be synchronous</span><br><span>diff --git a/sysmoOCTSIM/driver_init.c b/sysmoOCTSIM/driver_init.c</span><br><span>index 1a58ad9..5808f01 100644</span><br><span>--- a/sysmoOCTSIM/driver_init.c</span><br><span>+++ b/sysmoOCTSIM/driver_init.c</span><br><span>@@ -32,9 +32,6 @@</span><br><span> /*! The buffer size for USART */</span><br><span> #define SIM6_BUFFER_SIZE 16</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! The buffer size for USART */</span><br><span style="color: hsl(0, 100%, 40%);">-#define UART_DEBUG_BUFFER_SIZE 16</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> struct usart_async_descriptor SIM0;</span><br><span> struct usart_async_descriptor SIM1;</span><br><span> struct usart_async_descriptor SIM2;</span><br><span>@@ -42,7 +39,6 @@</span><br><span> struct usart_async_descriptor SIM4;</span><br><span> struct usart_async_descriptor SIM5;</span><br><span> struct usart_async_descriptor SIM6;</span><br><span style="color: hsl(0, 100%, 40%);">-struct usart_async_descriptor UART_debug;</span><br><span> </span><br><span> static uint8_t SIM0_buffer[SIM0_BUFFER_SIZE];</span><br><span> static uint8_t SIM1_buffer[SIM1_BUFFER_SIZE];</span><br><span>@@ -51,7 +47,8 @@</span><br><span> static uint8_t SIM4_buffer[SIM4_BUFFER_SIZE];</span><br><span> static uint8_t SIM5_buffer[SIM5_BUFFER_SIZE];</span><br><span> static uint8_t SIM6_buffer[SIM6_BUFFER_SIZE];</span><br><span style="color: hsl(0, 100%, 40%);">-static uint8_t UART_debug_buffer[UART_DEBUG_BUFFER_SIZE];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct usart_sync_descriptor UART_debug;</span><br><span> </span><br><span> /**</span><br><span>  * \brief USART Clock initialization function</span><br><span>@@ -312,26 +309,7 @@</span><br><span>     SIM6_PORT_init();</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief USART Clock initialization function</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Enables register interface and peripheral clock</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void UART_debug_CLOCK_init()</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));</span><br><span style="color: hsl(0, 100%, 40%);">-        hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief USART pinmux initialization function</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Set each required pin to USART functionality</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void UART_debug_PORT_init()</span><br><span style="color: hsl(120, 100%, 40%);">+void UART_debug_PORT_init(void)</span><br><span> {</span><br><span> </span><br><span>  gpio_set_pin_function(UART_TX, PINMUX_PB30C_SERCOM7_PAD0);</span><br><span>@@ -339,15 +317,18 @@</span><br><span>   gpio_set_pin_function(UART_RX, PINMUX_PB31C_SERCOM7_PAD1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief USART initialization function</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Enables USART peripheral, clocks and initializes USART driver</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(120, 100%, 40%);">+void UART_debug_CLOCK_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));</span><br><span style="color: hsl(120, 100%, 40%);">+      hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void UART_debug_init(void)</span><br><span> {</span><br><span>     UART_debug_CLOCK_init();</span><br><span style="color: hsl(0, 100%, 40%);">-        usart_async_init(&UART_debug, SERCOM7, UART_debug_buffer, UART_DEBUG_BUFFER_SIZE, (void *)NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+  usart_sync_init(&UART_debug, SERCOM7, (void *)NULL);</span><br><span>     UART_debug_PORT_init();</span><br><span> }</span><br><span> </span><br><span>@@ -860,6 +841,7 @@</span><br><span>       SIM4_init();</span><br><span>         SIM5_init();</span><br><span>         SIM6_init();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       UART_debug_init();</span><br><span> </span><br><span>       USB_DEVICE_INSTANCE_init();</span><br><span>diff --git a/sysmoOCTSIM/driver_init.h b/sysmoOCTSIM/driver_init.h</span><br><span>index a0fbb88..d809db8 100644</span><br><span>--- a/sysmoOCTSIM/driver_init.h</span><br><span>+++ b/sysmoOCTSIM/driver_init.h</span><br><span>@@ -28,7 +28,8 @@</span><br><span> #include <hal_usart_async.h></span><br><span> #include <hal_usart_async.h></span><br><span> #include <hal_usart_async.h></span><br><span style="color: hsl(0, 100%, 40%);">-#include <hal_usart_async.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <hal_usart_sync.h></span><br><span> </span><br><span> #include "hal_usb_device.h"</span><br><span> </span><br><span>@@ -39,7 +40,8 @@</span><br><span> extern struct usart_async_descriptor SIM4;</span><br><span> extern struct usart_async_descriptor SIM5;</span><br><span> extern struct usart_async_descriptor SIM6;</span><br><span style="color: hsl(0, 100%, 40%);">-extern struct usart_async_descriptor UART_debug;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+extern struct usart_sync_descriptor UART_debug;</span><br><span> </span><br><span> void SIM0_PORT_init(void);</span><br><span> void SIM0_CLOCK_init(void);</span><br><span>diff --git a/sysmoOCTSIM/examples/driver_examples.c b/sysmoOCTSIM/examples/driver_examples.c</span><br><span>index 14f1ae5..4ab0ef4 100644</span><br><span>--- a/sysmoOCTSIM/examples/driver_examples.c</span><br><span>+++ b/sysmoOCTSIM/examples/driver_examples.c</span><br><span>@@ -215,29 +215,12 @@</span><br><span> </span><br><span> /**</span><br><span>  * Example of using UART_debug to write "Hello World" using the IO abstraction.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Since the driver is asynchronous we need to use statically allocated memory for string</span><br><span style="color: hsl(0, 100%, 40%);">- * because driver initiates transfer and then returns before the transmission is completed.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Once transfer has been completed the tx_cb function will be called.</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static uint8_t example_UART_debug[12] = "Hello World!";</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void tx_cb_UART_debug(const struct usart_async_descriptor *const io_descr)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-       /* Transfer completed */</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> void UART_debug_example(void)</span><br><span> {</span><br><span>      struct io_descriptor *io;</span><br><span style="color: hsl(120, 100%, 40%);">+     usart_sync_get_io_descriptor(&UART_debug, &io);</span><br><span style="color: hsl(120, 100%, 40%);">+       usart_sync_enable(&UART_debug);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- usart_async_register_callback(&UART_debug, USART_ASYNC_TXC_CB, tx_cb_UART_debug);</span><br><span style="color: hsl(0, 100%, 40%);">-   /*usart_async_register_callback(&UART_debug, USART_ASYNC_RXC_CB, rx_cb);</span><br><span style="color: hsl(0, 100%, 40%);">-    usart_async_register_callback(&UART_debug, USART_ASYNC_ERROR_CB, err_cb);*/</span><br><span style="color: hsl(0, 100%, 40%);">- usart_async_get_io_descriptor(&UART_debug, &io);</span><br><span style="color: hsl(0, 100%, 40%);">-        usart_async_enable(&UART_debug);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    io_write(io, example_UART_debug, 12);</span><br><span style="color: hsl(120, 100%, 40%);">+ io_write(io, (uint8_t *)"Hello World!", 12);</span><br><span> }</span><br><span>diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile</span><br><span>index 5e3c38c..1c90257 100644</span><br><span>--- a/sysmoOCTSIM/gcc/Makefile</span><br><span>+++ b/sysmoOCTSIM/gcc/Makefile</span><br><span>@@ -26,32 +26,37 @@</span><br><span> # List the subdirectories for creating object files</span><br><span> SUB_DIRS +=  \</span><br><span>  \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/pm \</span><br><span style="color: hsl(120, 100%, 40%);">+hal/src \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/ramecc \</span><br><span style="color: hsl(120, 100%, 40%);">+examples \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/oscctrl \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_redirect/gcc \</span><br><span> gcc \</span><br><span> hpl/osc32kctrl \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/ramecc \</span><br><span style="color: hsl(120, 100%, 40%);">+usb \</span><br><span> hpl/dmac \</span><br><span> usb/class/cdc/device \</span><br><span style="color: hsl(0, 100%, 40%);">-hal/src \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/mclk \</span><br><span style="color: hsl(0, 100%, 40%);">-usb \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_redirect \</span><br><span> hal/utils/src \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/sercom \</span><br><span style="color: hsl(0, 100%, 40%);">-examples \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/gclk \</span><br><span style="color: hsl(0, 100%, 40%);">-usb/device \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/oscctrl \</span><br><span style="color: hsl(0, 100%, 40%);">-gcc/gcc \</span><br><span> hpl/usb \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/core \</span><br><span style="color: hsl(0, 100%, 40%);">-hpl/cmcc</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/pm \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/cmcc \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/gclk \</span><br><span style="color: hsl(120, 100%, 40%);">+gcc/gcc \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/mclk \</span><br><span style="color: hsl(120, 100%, 40%);">+usb/device \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/sercom \</span><br><span style="color: hsl(120, 100%, 40%);">+hpl/core</span><br><span> </span><br><span> # List the object files</span><br><span> OBJS +=  \</span><br><span> hal/src/hal_io.o \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_redirect/stdio_io.o \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_redirect/gcc/write.o \</span><br><span> hpl/core/hpl_core_m4.o \</span><br><span> usb/class/cdc/device/cdcdf_acm.o \</span><br><span> hal/utils/src/utils_syscalls.o \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_redirect/gcc/read.o \</span><br><span> usb_start.o \</span><br><span> gcc/system_same54.o \</span><br><span> hpl/usb/hpl_usb.o \</span><br><span>@@ -63,8 +68,10 @@</span><br><span> hal/utils/src/utils_assert.o \</span><br><span> hpl/dmac/hpl_dmac.o \</span><br><span> hpl/oscctrl/hpl_oscctrl.o \</span><br><span style="color: hsl(120, 100%, 40%);">+hal/src/hal_usart_sync.o \</span><br><span> hpl/mclk/hpl_mclk.o \</span><br><span> hpl/ramecc/hpl_ramecc.o \</span><br><span style="color: hsl(120, 100%, 40%);">+stdio_start.o \</span><br><span> usb/usb_protocol.o \</span><br><span> hal/src/hal_init.o \</span><br><span> gcc/gcc/startup_same54.o \</span><br><span>@@ -90,9 +97,12 @@</span><br><span> </span><br><span> OBJS_AS_ARGS +=  \</span><br><span> "hal/src/hal_io.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/stdio_io.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/gcc/write.o" \</span><br><span> "hpl/core/hpl_core_m4.o" \</span><br><span> "usb/class/cdc/device/cdcdf_acm.o" \</span><br><span> "hal/utils/src/utils_syscalls.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/gcc/read.o" \</span><br><span> "usb_start.o" \</span><br><span> "gcc/system_same54.o" \</span><br><span> "hpl/usb/hpl_usb.o" \</span><br><span>@@ -104,8 +114,10 @@</span><br><span> "hal/utils/src/utils_assert.o" \</span><br><span> "hpl/dmac/hpl_dmac.o" \</span><br><span> "hpl/oscctrl/hpl_oscctrl.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"hal/src/hal_usart_sync.o" \</span><br><span> "hpl/mclk/hpl_mclk.o" \</span><br><span> "hpl/ramecc/hpl_ramecc.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_start.o" \</span><br><span> "usb/usb_protocol.o" \</span><br><span> "hal/src/hal_init.o" \</span><br><span> "gcc/gcc/startup_same54.o" \</span><br><span>@@ -133,12 +145,14 @@</span><br><span> DEPS := $(OBJS:%.o=%.d)</span><br><span> </span><br><span> DEPS_AS_ARGS +=  \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/stdio_io.d" \</span><br><span> "hal/utils/src/utils_event.d" \</span><br><span> "hal/src/hal_io.d" \</span><br><span> "hpl/ramecc/hpl_ramecc.d" \</span><br><span> "hpl/core/hpl_core_m4.d" \</span><br><span> "hal/utils/src/utils_syscalls.d" \</span><br><span> "usb/class/cdc/device/cdcdf_acm.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/gcc/write.d" \</span><br><span> "gcc/gcc/startup_same54.d" \</span><br><span> "hpl/usb/hpl_usb.d" \</span><br><span> "hal/utils/src/utils_list.d" \</span><br><span>@@ -149,12 +163,15 @@</span><br><span> "hpl/core/hpl_init.d" \</span><br><span> "hpl/pm/hpl_pm.d" \</span><br><span> "usb/usb_protocol.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_start.d" \</span><br><span> "hpl/gclk/hpl_gclk.d" \</span><br><span> "hal/src/hal_usb_device.d" \</span><br><span> "usb_start.d" \</span><br><span> "hal/src/hal_init.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"hal/src/hal_usart_sync.d" \</span><br><span> "hpl/mclk/hpl_mclk.d" \</span><br><span> "driver_init.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"stdio_redirect/gcc/read.d" \</span><br><span> "hal/src/hal_usart_async.d" \</span><br><span> "hpl/osc32kctrl/hpl_osc32kctrl.d" \</span><br><span> "main.d" \</span><br><span>@@ -218,7 +235,7 @@</span><br><span>        @echo ARM/GNU C Compiler</span><br><span>     $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../config" -I"../stdio_redirect" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>      @echo Finished building: $<</span><br><span> </span><br><span>@@ -227,7 +244,7 @@</span><br><span>     @echo ARM/GNU Assembler</span><br><span>      $(QUOTE)arm-none-eabi-as$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../config" -I"../stdio_redirect" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>       @echo Finished building: $<</span><br><span> </span><br><span>@@ -236,7 +253,7 @@</span><br><span>     @echo ARM/GNU Preprocessing Assembler</span><br><span>        $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54N19A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/sercom" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../config" -I"../stdio_redirect" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>      @echo Finished building: $<</span><br><span> </span><br><span>diff --git a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c</span><br><span>index f235115..b14e720 100644</span><br><span>--- a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c</span><br><span>+++ b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c</span><br><span>@@ -177,8 +177,6 @@</span><br><span> </span><br><span> static struct _usart_async_device *_sercom6_dev = NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static struct _usart_async_device *_sercom7_dev = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> static uint8_t _get_sercom_index(const void *const hw);</span><br><span> static uint8_t _sercom_get_irq_num(const void *const hw);</span><br><span> static void    _sercom_init_irq_param(const void *const hw, void *dev);</span><br><span>@@ -667,10 +665,6 @@</span><br><span>        if (hw == SERCOM6) {</span><br><span>                 _sercom6_dev = (struct _usart_async_device *)dev;</span><br><span>    }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       if (hw == SERCOM7) {</span><br><span style="color: hsl(0, 100%, 40%);">-            _sercom7_dev = (struct _usart_async_device *)dev;</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span>@@ -2634,35 +2628,6 @@</span><br><span>   _sercom_usart_interrupt_handler(_sercom6_dev);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \internal Sercom interrupt handler</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void SERCOM7_0_Handler(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- _sercom_usart_interrupt_handler(_sercom7_dev);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \internal Sercom interrupt handler</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void SERCOM7_1_Handler(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- _sercom_usart_interrupt_handler(_sercom7_dev);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \internal Sercom interrupt handler</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void SERCOM7_2_Handler(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- _sercom_usart_interrupt_handler(_sercom7_dev);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \internal Sercom interrupt handler</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void SERCOM7_3_Handler(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- _sercom_usart_interrupt_handler(_sercom7_dev);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> int32_t _spi_m_sync_init(struct _spi_m_sync_dev *dev, void *const hw)</span><br><span> {</span><br><span>        const struct sercomspi_regs_cfg *regs = _spi_get_regs((uint32_t)hw);</span><br><span>diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c</span><br><span>index 50e82c6..c79d5aa 100644</span><br><span>--- a/sysmoOCTSIM/main.c</span><br><span>+++ b/sysmoOCTSIM/main.c</span><br><span>@@ -27,20 +27,6 @@</span><br><span> #include "octsim_i2c.h"</span><br><span> #include "ncn8025.h"</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-volatile static bool data_arrived = false;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void tx_cb_UART_debug(const struct usart_async_descriptor *const io_descr)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-   /* Transfer completed */</span><br><span style="color: hsl(0, 100%, 40%);">-        //gpio_toggle_pin_level(LED_system);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void rx_cb_UART_debug(const struct usart_async_descriptor *const io_descr)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- /* Receive completed */</span><br><span style="color: hsl(0, 100%, 40%);">- gpio_toggle_pin_level(USER_LED);</span><br><span style="color: hsl(0, 100%, 40%);">-        data_arrived = true;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span> </span><br><span> static void board_init()</span><br><span> {</span><br><span>@@ -65,23 +51,18 @@</span><br><span> {</span><br><span>        atmel_start_init();</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- usart_async_register_callback(&UART_debug, USART_ASYNC_TXC_CB, tx_cb_UART_debug);</span><br><span style="color: hsl(0, 100%, 40%);">-   usart_async_register_callback(&UART_debug, USART_ASYNC_RXC_CB, rx_cb_UART_debug);</span><br><span style="color: hsl(0, 100%, 40%);">-   usart_async_enable(&UART_debug);</span><br><span style="color: hsl(120, 100%, 40%);">+  usart_sync_enable(&UART_debug);</span><br><span> </span><br><span>      usb_start();</span><br><span> </span><br><span>     board_init();</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-       const char* welcome = "\r\n\r\nsysmocom sysmoOCTSIM\r\n";</span><br><span style="color: hsl(0, 100%, 40%);">-     while (io_write(&UART_debug.io, (const uint8_t*)welcome, strlen(welcome)) != strlen(welcome)); // print welcome message</span><br><span style="color: hsl(120, 100%, 40%);">+   printf("\r\n\r\nsysmocom sysmoOCTSIM\r\n");</span><br><span>        while (true) { // main loop</span><br><span style="color: hsl(0, 100%, 40%);">-             if (data_arrived) { // input on UART debug</span><br><span style="color: hsl(0, 100%, 40%);">-                      data_arrived = false; // clear flag</span><br><span style="color: hsl(0, 100%, 40%);">-                     uint8_t recv_char; // to store the input</span><br><span style="color: hsl(0, 100%, 40%);">-                        while (io_read(&UART_debug.io, &recv_char, 1) == 1) { // read input</span><br><span style="color: hsl(0, 100%, 40%);">-                             while (io_write(&UART_debug.io, &recv_char, 1) != 1); // echo back to output</span><br><span style="color: hsl(0, 100%, 40%);">-                    }</span><br><span style="color: hsl(120, 100%, 40%);">+             if (usart_sync_is_rx_not_empty(&UART_debug)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    gpio_toggle_pin_level(USER_LED);</span><br><span style="color: hsl(120, 100%, 40%);">+                      int c = getchar();</span><br><span style="color: hsl(120, 100%, 40%);">+                    putchar(c);</span><br><span>          }</span><br><span>    }</span><br><span> }</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/gcc/read.c b/sysmoOCTSIM/stdio_redirect/gcc/read.c</span><br><span>new file mode 100644</span><br><span>index 0000000..90e4618</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/gcc/read.c</span><br><span>@@ -0,0 +1,53 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int __attribute__((weak)) _read(int file, char *ptr, int len); /* Remove GCC compiler warning */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int __attribute__((weak)) _read(int file, char *ptr, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      int n = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (file != 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+              return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   n = stdio_io_read((uint8_t *)ptr, len);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (n < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return n;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/gcc/write.c b/sysmoOCTSIM/stdio_redirect/gcc/write.c</span><br><span>new file mode 100644</span><br><span>index 0000000..44fa815</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/gcc/write.c</span><br><span>@@ -0,0 +1,53 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int __attribute__((weak)) _write(int file, char *ptr, int len); /* Remove GCC compiler warning */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int __attribute__((weak)) _write(int file, char *ptr, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   int n = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if ((file != 1) && (file != 2) && (file != 3)) {</span><br><span style="color: hsl(120, 100%, 40%);">+              return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   n = stdio_io_write((const uint8_t *)ptr, len);</span><br><span style="color: hsl(120, 100%, 40%);">+        if (n < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return n;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/iar/read.c b/sysmoOCTSIM/stdio_redirect/iar/read.c</span><br><span>new file mode 100644</span><br><span>index 0000000..df192cb</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/iar/read.c</span><br><span>@@ -0,0 +1,114 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _UNIT_TEST_</span><br><span style="color: hsl(120, 100%, 40%);">+#include <yfuns.h></span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+#define _STD_BEGIN</span><br><span style="color: hsl(120, 100%, 40%);">+#define _STD_END</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_ERROR ((size_t)-1) /* For __read and __write. */</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDIN 0</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDOUT 1</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDERR 2</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#if (__VER__ < 8010000)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */</span><br><span style="color: hsl(120, 100%, 40%);">+_STD_BEGIN</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma module_name = "?__read"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Reads a number of bytes, at most \a size, into the memory area</span><br><span style="color: hsl(120, 100%, 40%);">+ *         pointed to by \a buffer.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param handle File handle to read from.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param buffer Pointer to buffer to write read bytes to.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param size Number of bytes to read.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return The number of bytes read, \c 0 at the end of the file, or</span><br><span style="color: hsl(120, 100%, 40%);">+ *         \c _LLIO_ERROR on failure.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+size_t __read(int handle, unsigned char *buffer, size_t size)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int n = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    /* This implementation only reads from stdin.</span><br><span style="color: hsl(120, 100%, 40%);">+  * For all other file handles, it returns failure. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (handle != _LLIO_STDIN) {</span><br><span style="color: hsl(120, 100%, 40%);">+          return _LLIO_ERROR;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   n = stdio_io_read((uint8_t *)buffer, size);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (n < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return _LLIO_ERROR;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     return n;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10</span><br><span style="color: hsl(120, 100%, 40%);">+ * the implementation is empty to be compatible with old IAR version.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int __close(int handle)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     (void)(handle);</span><br><span style="color: hsl(120, 100%, 40%);">+       return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef __GNUC__</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10</span><br><span style="color: hsl(120, 100%, 40%);">+ * the implementation is empty to be compatible with old IAR version.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int remove(const char *val)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       (void)(val);</span><br><span style="color: hsl(120, 100%, 40%);">+  return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief This routine is required by IAR DLIB library since EWAVR V6.10</span><br><span style="color: hsl(120, 100%, 40%);">+ * the implementation is empty to be compatible with old IAR version.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+long __lseek(int handle, long val, int val2)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        (void)(handle);</span><br><span style="color: hsl(120, 100%, 40%);">+       (void)(val2);</span><br><span style="color: hsl(120, 100%, 40%);">+ return val;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#if (__VER__ < 8010000)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */</span><br><span style="color: hsl(120, 100%, 40%);">+_STD_END</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/iar/write.c b/sysmoOCTSIM/stdio_redirect/iar/write.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7bc8f78</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/iar/write.c</span><br><span>@@ -0,0 +1,94 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _UNIT_TEST_</span><br><span style="color: hsl(120, 100%, 40%);">+#include <yfuns.h></span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+#define _STD_BEGIN</span><br><span style="color: hsl(120, 100%, 40%);">+#define _STD_END</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_ERROR ((size_t)-1) /* For __read and __write. */</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDIN 0</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDOUT 1</span><br><span style="color: hsl(120, 100%, 40%);">+#define _LLIO_STDERR 2</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#if (__VER__ < 8010000)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */</span><br><span style="color: hsl(120, 100%, 40%);">+_STD_BEGIN</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma module_name = "?__write"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Writes a number of bytes, at most \a size, from the memory area</span><br><span style="color: hsl(120, 100%, 40%);">+ *         pointed to by \a buffer.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * If \a buffer is zero then \ref __write performs flushing of internal buffers,</span><br><span style="color: hsl(120, 100%, 40%);">+ * if any. In this case, \a handle can be \c -1 to indicate that all handles</span><br><span style="color: hsl(120, 100%, 40%);">+ * should be flushed.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param handle File handle to write to.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param buffer Pointer to buffer to read bytes to write from.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param size Number of bytes to write.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return The number of bytes written, or \c _LLIO_ERROR on failure.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+size_t __write(int handle, const unsigned char *buffer, size_t size)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       int n = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (buffer == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+            /* This means that we should flush internal buffers. */</span><br><span style="color: hsl(120, 100%, 40%);">+               return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* This implementation only writes to stdout and stderr.</span><br><span style="color: hsl(120, 100%, 40%);">+       * For all other file handles, it returns failure. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return _LLIO_ERROR;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   n = stdio_io_write((const uint8_t *)buffer, size);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (n < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return _LLIO_ERROR;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return n;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#if (__VER__ < 8010000)</span><br><span style="color: hsl(120, 100%, 40%);">+/* Refer http://ftp.iar.se/WWWfiles/arm/webic/doc/EWARM_MigrationGuide.ENU.pdf */</span><br><span style="color: hsl(120, 100%, 40%);">+_STD_END</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/keil/Retarget.c b/sysmoOCTSIM/stdio_redirect/keil/Retarget.c</span><br><span>new file mode 100644</span><br><span>index 0000000..205e7e5</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/keil/Retarget.c</span><br><span>@@ -0,0 +1,107 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef _UNIT_TEST_</span><br><span style="color: hsl(120, 100%, 40%);">+#undef fputc</span><br><span style="color: hsl(120, 100%, 40%);">+#undef fgetc</span><br><span style="color: hsl(120, 100%, 40%);">+#undef ferror</span><br><span style="color: hsl(120, 100%, 40%);">+#define fputc ut_fputc</span><br><span style="color: hsl(120, 100%, 40%);">+#define fgetc ut_fgetc</span><br><span style="color: hsl(120, 100%, 40%);">+#define ferror ut_ferror</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Disable semihosting */</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(__GNUC__) && (__ARMCOMPILER_VERSION > 6000000) /*  Keil MDK with ARM Compiler 6 */</span><br><span style="color: hsl(120, 100%, 40%);">+__asm(".global __use_no_semihosting\n\t");</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma import(__use_no_semihosting_swi)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef __GNUC__</span><br><span style="color: hsl(120, 100%, 40%);">+struct __FILE {</span><br><span style="color: hsl(120, 100%, 40%);">+    int handle;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+FILE __stdout;</span><br><span style="color: hsl(120, 100%, 40%);">+FILE __stdin;</span><br><span style="color: hsl(120, 100%, 40%);">+FILE __stderr;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int fputc(int ch, FILE *f)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       if ((f == stdout) || (f == stderr)) {</span><br><span style="color: hsl(120, 100%, 40%);">+         uint8_t tmp = (uint8_t)ch;</span><br><span style="color: hsl(120, 100%, 40%);">+            if (stdio_io_write(&tmp, 1) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     return EOF;</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+             return ch;</span><br><span style="color: hsl(120, 100%, 40%);">+    } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              return EOF;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int fgetc(FILE *f)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f == stdin) {</span><br><span style="color: hsl(120, 100%, 40%);">+             uint8_t tmp = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+              if (stdio_io_read(&tmp, 1) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      return EOF;</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+             return tmp;</span><br><span style="color: hsl(120, 100%, 40%);">+   } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              return EOF;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void _ttywrch(int ch)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t tmp = (uint8_t)ch;</span><br><span style="color: hsl(120, 100%, 40%);">+    stdio_io_write(&tmp, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int ferror(FILE *f)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     (void)f;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* Your implementation of ferror */</span><br><span style="color: hsl(120, 100%, 40%);">+   return EOF;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void _sys_exit(int return_code)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  (void)return_code;</span><br><span style="color: hsl(120, 100%, 40%);">+    while (1) {</span><br><span style="color: hsl(120, 100%, 40%);">+   }; /* endless loop */</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/stdio_io.c b/sysmoOCTSIM/stdio_redirect/stdio_io.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7659f3d</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/stdio_io.c</span><br><span>@@ -0,0 +1,74 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection terminal</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** IO descriptor for STDIO access. */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct io_descriptor *stdio_io = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_io_init(struct io_descriptor *io)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(__GNUC__)</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Specify that stdout and stdin should not be buffered. */</span><br><span style="color: hsl(120, 100%, 40%);">+   setbuf(stdout, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ setbuf(stdin, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Note: Already the case in IAR's Normal DLIB default configuration</span><br><span style="color: hsl(120, 100%, 40%);">+       * and AVR GCC library:</span><br><span style="color: hsl(120, 100%, 40%);">+        * - printf() emits one character at a time.</span><br><span style="color: hsl(120, 100%, 40%);">+   * - getchar() requests only 1 byte to exit.</span><br><span style="color: hsl(120, 100%, 40%);">+   */</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+   stdio_io = io;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_io_set_io(struct io_descriptor *io)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        stdio_io = io;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t stdio_io_read(uint8_t *buf, const int32_t len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        if (stdio_io == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     return io_read(stdio_io, buf, len);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t stdio_io_write(const uint8_t *buf, const int32_t len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    if (stdio_io == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+               return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     return io_write(stdio_io, buf, len);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/stdio_redirect/stdio_io.h b/sysmoOCTSIM/stdio_redirect/stdio_io.h</span><br><span>new file mode 100644</span><br><span>index 0000000..973adad</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_redirect/stdio_io.h</span><br><span>@@ -0,0 +1,81 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief STDIO redirection terminal</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _STDIO_IO_H_INCLUDED</span><br><span style="color: hsl(120, 100%, 40%);">+#define _STDIO_IO_H_INCLUDED</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <hal_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+extern "C" {</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* __cplusplus */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \brief Initialize STDIO access</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] io Pointer to IO descriptor,</span><br><span style="color: hsl(120, 100%, 40%);">+ *                NULL to discard R/W without any error.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_io_init(struct io_descriptor *io);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \brief Change IO descriptor for terminal to R/W data</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] io Pointer to IO descriptor,</span><br><span style="color: hsl(120, 100%, 40%);">+ *                NULL to discard R/W without any error.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_io_set_io(struct io_descriptor *io);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \brief Read through specified terminal</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] buf Pointer to buffer to place read data</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len Data length in number of bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \return status</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \retval >=0 number of bytes read</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \retval <0 error</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t stdio_io_read(uint8_t *buf, const int32_t len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \brief Write through specified terminal</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] buf Pointer to buffer to place data to write</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len Data length in number of bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \return status</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \retval >=0 number of bytes read</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \retval <0 error</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t stdio_io_write(const uint8_t *buf, const int32_t len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* __cplusplus */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* _STDIO_IO_H_INCLUDED */</span><br><span>diff --git a/sysmoOCTSIM/stdio_start.c b/sysmoOCTSIM/stdio_start.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7450a08</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_start.c</span><br><span>@@ -0,0 +1,23 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Code generated from Atmel Start.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file will be overwritten when reconfiguring your Atmel Start project.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Please copy examples or other code you want to keep to a separate file or main.c</span><br><span style="color: hsl(120, 100%, 40%);">+ * to avoid loosing it when reconfiguring.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "atmel_start.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "stdio_start.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void STDIO_REDIRECT_0_example(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Print welcome message */</span><br><span style="color: hsl(120, 100%, 40%);">+   printf("\r\nHello ATMEL World!\r\n");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_redirect_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     usart_sync_enable(&UART_debug);</span><br><span style="color: hsl(120, 100%, 40%);">+   stdio_io_init(&UART_debug.io);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/stdio_start.h b/sysmoOCTSIM/stdio_start.h</span><br><span>new file mode 100644</span><br><span>index 0000000..bee5325</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/stdio_start.h</span><br><span>@@ -0,0 +1,31 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Code generated from Atmel Start.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file will be overwritten when reconfiguring your Atmel Start project.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Please copy examples or other code you want to keep to a separate file or main.c</span><br><span style="color: hsl(120, 100%, 40%);">+ * to avoid loosing it when reconfiguring.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef STDIO_MAIN_H</span><br><span style="color: hsl(120, 100%, 40%);">+#define STDIO_MAIN_H</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+extern "C" {</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* __cplusplus */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio_io.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void STDIO_REDIRECT_0_example(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Initialize STDIO Redirect</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void stdio_redirect_init(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef __cplusplus</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* __cplusplus */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* STDIO_MAIN_H */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13035">change 13035</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13035"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ccid-firmware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ibf4ba961d4bbf8d787558f38f3d557422587aad3 </div>
<div style="display:none"> Gerrit-Change-Number: 13035 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Kévin Redon <kredon@sysmocom.de> </div>