1 /*********************************************************************
2 * SEGGER Microcontroller GmbH *
3 * The Embedded Experts *
4 **********************************************************************
5 * *
6 * (c) 1995 - 2024 SEGGER Microcontroller GmbH *
7 * *
8 * www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11 * *
12 * SEGGER SystemView * Real-time application analysis *
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 SystemView and 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 * condition is met: *
25 * *
26 * o Redistributions of source code must retain the above copyright *
27 * notice, this condition and the following disclaimer. *
28 * *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
30 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
31 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
33 * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
34 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
36 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
37 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
40 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
41 * DAMAGE. *
42 * *
43 **********************************************************************
44 * *
45 * SystemView version: 3.58 *
46 * *
47 **********************************************************************
48 ---------------------------END-OF-HEADER------------------------------
49 File : SEGGER_RTT_Syscalls_IAR.c
50 Purpose : Low-level functions for using printf() via RTT in IAR.
51 To use RTT for printf output, include this file in your
52 application and set the Library Configuration to Normal.
53 Revision: $Rev: 24316 $
54 ----------------------------------------------------------------------
55 */
56 #ifdef __IAR_SYSTEMS_ICC__
57
58 //
59 // Since IAR EWARM V8 and EWRX V4, yfuns.h is considered as deprecated and LowLevelIOInterface.h
60 // shall be used instead. To not break any compatibility with older compiler versions, we have a
61 // version check in here.
62 //
63 #if ((defined __ICCARM__) && (__VER__ >= 8000000)) || ((defined __ICCRX__) && (__VER__ >= 400))
64 #include <LowLevelIOInterface.h>
65 #else
66 #include <yfuns.h>
67 #endif
68
69 #include "SEGGER_RTT.h"
70 #pragma module_name = "?__write"
71
72 /*********************************************************************
73 *
74 * Function prototypes
75 *
76 **********************************************************************
77 */
78 size_t __write(int handle, const unsigned char * buffer, size_t size);
79
80 /*********************************************************************
81 *
82 * Global functions
83 *
84 **********************************************************************
85 */
86 /*********************************************************************
87 *
88 * __write()
89 *
90 * Function description
91 * Low-level write function.
92 * Standard library subroutines will use this system routine
93 * for output to all files, including stdout.
94 * Write data via RTT.
95 */
__write(int handle,const unsigned char * buffer,size_t size)96 size_t __write(int handle, const unsigned char * buffer, size_t size) {
97 (void) handle; /* Not used, avoid warning */
98 SEGGER_RTT_Write(0, (const char*)buffer, size);
99 return size;
100 }
101
102 /*********************************************************************
103 *
104 * __write_buffered()
105 *
106 * Function description
107 * Low-level write function.
108 * Standard library subroutines will use this system routine
109 * for output to all files, including stdout.
110 * Write data via RTT.
111 */
__write_buffered(int handle,const unsigned char * buffer,size_t size)112 size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) {
113 (void) handle; /* Not used, avoid warning */
114 SEGGER_RTT_Write(0, (const char*)buffer, size);
115 return size;
116 }
117
118 #endif
119 /****** End Of File *************************************************/
120