source: trunk/firmware/RTT - Kopie/SEGGER_RTT_Syscalls_GCC.c

Last change on this file was 6, checked in by f.jahn, 3 months ago
File size: 5.3 KB
Line 
1/*********************************************************************
2*                    SEGGER Microcontroller GmbH                     *
3*                        The Embedded Experts                        *
4**********************************************************************
5*                                                                    *
6*            (c) 2014 - 2019 SEGGER Microcontroller GmbH             *
7*                                                                    *
8*           www.segger.com     Support: support@segger.com           *
9*                                                                    *
10**********************************************************************
11*                                                                    *
12* All rights reserved.                                               *
13*                                                                    *
14* Redistribution and use in source and binary forms, with or         *
15* without modification, are permitted provided that the following    *
16* conditions are met:                                                *
17*                                                                    *
18* - Redistributions of source code must retain the above copyright   *
19*   notice, this list of conditions and the following disclaimer.    *
20*                                                                    *
21* - Neither the name of SEGGER Microcontroller GmbH                  *
22*   nor the names of its contributors may be used to endorse or      *
23*   promote products derived from this software without specific     *
24*   prior written permission.                                        *
25*                                                                    *
26* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             *
27* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        *
28* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           *
29* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           *
30* DISCLAIMED.                                                        *
31* IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        *
32* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           *
33* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  *
34* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    *
35* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      *
36* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          *
37* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  *
38* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
39* DAMAGE.                                                            *
40*                                                                    *
41**********************************************************************
42*                                                                    *
43*       RTT version: 5.12e                                           *
44*                                                                    *
45**********************************************************************
46--------  END-OF-HEADER  ---------------------------------------------
47File    : SEGGER_RTT_Syscalls_GCC.c
48Purpose : Low-level functions for using printf() via RTT in GCC.
49          To use RTT for printf output, include this file in your
50          application.
51----------------------------------------------------------------------
52*/
53//#include <reent.h>  // required for _write_r
54#include "SEGGER_RTT.h"
55
56
57/*********************************************************************
58*
59*       Types
60*
61**********************************************************************
62*/
63//
64// If necessary define the _reent struct
65// to match the one passed by the used standard library.
66//
67struct _reent;
68
69/*********************************************************************
70*
71*       Function prototypes
72*
73**********************************************************************
74*/
75int _write(int file, char *ptr, int len);
76int _write_r(struct _reent *r, int file, const void *ptr, int len);
77
78/*********************************************************************
79*
80*       Global functions
81*
82**********************************************************************
83*/
84
85/*********************************************************************
86*
87*       _write()
88*
89* Function description
90*   Low-level write function.
91*   libc subroutines will use this system routine for output to all files,
92*   including stdout.
93*   Write data via RTT.
94*/
95int _write(int file, char *ptr, int len) {
96  (void) file;  /* Not used, avoid warning */
97  SEGGER_RTT_Write(0, ptr, len);
98  return len;
99}
100
101/*********************************************************************
102*
103*       _write_r()
104*
105* Function description
106*   Low-level reentrant write function.
107*   libc subroutines will use this system routine for output to all files,
108*   including stdout.
109*   Write data via RTT.
110*/
111int _write_r(struct _reent *r, int file, const void *ptr, int len) {
112  (void) file;  /* Not used, avoid warning */
113  (void) r;     /* Not used, avoid warning */
114  SEGGER_RTT_Write(0, ptr, len);
115  return len;
116}
117
118/****** End Of File *************************************************/
Note: See TracBrowser for help on using the repository browser.