xref: /btstack/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_IAR.c (revision f2eb0907497ae6c49729a66e13ab73e9da185656)
1 /*********************************************************************
2 *                    SEGGER Microcontroller GmbH                     *
3 *                        The Embedded Experts                        *
4 **********************************************************************
5 *                                                                    *
6 *            (c) 1995 - 2019 SEGGER Microcontroller GmbH             *
7 *                                                                    *
8 *       www.segger.com     Support: [email protected]               *
9 *                                                                    *
10 **********************************************************************
11 *                                                                    *
12 *       SEGGER RTT * Real Time Transfer for embedded targets         *
13 *                                                                    *
14 **********************************************************************
15 *                                                                    *
16 * All rights reserved.                                               *
17 *                                                                    *
18 * SEGGER strongly recommends to not make any changes                 *
19 * to or modify the source code of this software in order to stay     *
20 * compatible with the RTT protocol and J-Link.                       *
21 *                                                                    *
22 * Redistribution and use in source and binary forms, with or         *
23 * without modification, are permitted provided that the following    *
24 * conditions are met:                                                *
25 *                                                                    *
26 * o Redistributions of source code must retain the above copyright   *
27 *   notice, this list of conditions and the following disclaimer.    *
28 *                                                                    *
29 * o Redistributions in binary form must reproduce the above          *
30 *   copyright notice, this list of conditions and the following      *
31 *   disclaimer in the documentation and/or other materials provided  *
32 *   with the distribution.                                           *
33 *                                                                    *
34 * o Neither the name of SEGGER Microcontroller GmbH                  *
35 *   nor the names of its contributors may be used to endorse or      *
36 *   promote products derived from this software without specific     *
37 *   prior written permission.                                        *
38 *                                                                    *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
40 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
41 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
43 * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
44 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
46 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
47 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
48 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
50 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
51 * DAMAGE.                                                            *
52 *                                                                    *
53 **********************************************************************
54 ---------------------------END-OF-HEADER------------------------------
55 File    : SEGGER_RTT_Syscalls_IAR.c
56 Purpose : Low-level functions for using printf() via RTT in IAR.
57           To use RTT for printf output, include this file in your
58           application and set the Library Configuration to Normal.
59 Revision: $Rev: 16282 $
60 ----------------------------------------------------------------------
61 */
62 #ifdef __IAR_SYSTEMS_ICC__
63 
64 //
65 // Since IAR EWARM V8 and EWRX V4, yfuns.h is considered as deprecated and LowLevelIOInterface.h
66 // shall be used instead. To not break any compatibility with older compiler versions, we have a
67 // version check in here.
68 //
69 #if ((defined __ICCARM__) && (__VER__ >= 8000000)) || ((defined __ICCRX__)  && (__VER__ >= 400))
70   #include <LowLevelIOInterface.h>
71 #else
72   #include <yfuns.h>
73 #endif
74 
75 #include "SEGGER_RTT.h"
76 #pragma module_name = "?__write"
77 
78 /*********************************************************************
79 *
80 *       Function prototypes
81 *
82 **********************************************************************
83 */
84 size_t __write(int handle, const unsigned char * buffer, size_t size);
85 
86 /*********************************************************************
87 *
88 *       Global functions
89 *
90 **********************************************************************
91 */
92 /*********************************************************************
93 *
94 *       __write()
95 *
96 * Function description
97 *   Low-level write function.
98 *   Standard library subroutines will use this system routine
99 *   for output to all files, including stdout.
100 *   Write data via RTT.
101 */
102 size_t __write(int handle, const unsigned char * buffer, size_t size) {
103   (void) handle;  /* Not used, avoid warning */
104   SEGGER_RTT_Write(0, (const char*)buffer, size);
105   return size;
106 }
107 
108 /*********************************************************************
109 *
110 *       __write_buffered()
111 *
112 * Function description
113 *   Low-level write function.
114 *   Standard library subroutines will use this system routine
115 *   for output to all files, including stdout.
116 *   Write data via RTT.
117 */
118 size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) {
119   (void) handle;  /* Not used, avoid warning */
120   SEGGER_RTT_Write(0, (const char*)buffer, size);
121   return size;
122 }
123 
124 #endif
125 /****** End Of File *************************************************/
126