RTT_Syscalls_GCC.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*********************************************************************
  2. * SEGGER MICROCONTROLLER GmbH & Co. KG *
  3. * Solutions for real time microcontroller applications *
  4. **********************************************************************
  5. * *
  6. * (c) 2014 - 2015 SEGGER Microcontroller GmbH & Co. KG *
  7. * *
  8. * www.segger.com Support: support@segger.com *
  9. * *
  10. **********************************************************************
  11. * *
  12. * All rights reserved. *
  13. * *
  14. * * This software may in its unmodified form be freely redistributed *
  15. * in source form. *
  16. * * The source code may be modified, provided the source code *
  17. * retains the above copyright notice, this list of conditions and *
  18. * the following disclaimer. *
  19. * * Modified versions of this software in source or linkable form *
  20. * may not be distributed without prior consent of SEGGER. *
  21. * * This software may only be used for communication with SEGGER *
  22. * J-Link debug probes. *
  23. * *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  25. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
  26. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
  27. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
  28. * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
  29. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
  31. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
  32. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  33. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
  35. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
  36. * DAMAGE. *
  37. * *
  38. **********************************************************************
  39. -------- END-OF-HEADER ---------------------------------------------
  40. File : SEGGER_RTT_Syscalls_GCC.c
  41. Purpose : Low-level functions for using printf() via RTT in GCC.
  42. To use RTT for printf output, include this file in your
  43. application.
  44. ----------------------------------------------------------------------
  45. */
  46. #if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
  47. #include <stdlib.h>
  48. #include "SEGGER_RTT.h"
  49. /*********************************************************************
  50. *
  51. * Function prototypes
  52. *
  53. **********************************************************************
  54. */
  55. int _write(int file, char *ptr, int len);
  56. int _write_r(struct _reent *r, int file, char *ptr, int len);
  57. /*********************************************************************
  58. *
  59. * Global functions
  60. *
  61. **********************************************************************
  62. */
  63. /*********************************************************************
  64. *
  65. * _write()
  66. *
  67. * Function description
  68. * Low-level write function.
  69. * libc subroutines will use this system routine for output to all files,
  70. * including stdout.
  71. * Write data via RTT.
  72. */
  73. int _write(int file, char *ptr, int len) {
  74. (void) file; /* Not used, avoid warning */
  75. SEGGER_RTT_Write(0, ptr, len);
  76. return len;
  77. }
  78. /*********************************************************************
  79. *
  80. * _write_r()
  81. *
  82. * Function description
  83. * Low-level reentrant write function.
  84. * libc subroutines will use this system routine for output to all files,
  85. * including stdout.
  86. * Write data via RTT.
  87. */
  88. int _write_r(struct _reent *r, int file, char *ptr, int len) {
  89. (void) file; /* Not used, avoid warning */
  90. (void) r; /* Not used, avoid warning */
  91. SEGGER_RTT_Write(0, ptr, len);
  92. return len;
  93. }
  94. #endif
  95. /****** End Of File *************************************************/