SEGGER_RTT_Syscalls_IAR.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*********************************************************************
  2. * SEGGER Microcontroller GmbH & Co. KG *
  3. * The Embedded Experts *
  4. **********************************************************************
  5. * *
  6. * (c) 2014 - 2017 SEGGER Microcontroller GmbH & Co. KG *
  7. * *
  8. * www.segger.com Support: support@segger.com *
  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 & Co. KG *
  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. * *
  55. * RTT version: 6.18a *
  56. * *
  57. **********************************************************************
  58. ---------------------------END-OF-HEADER------------------------------
  59. File : SEGGER_RTT_Syscalls_IAR.c
  60. Purpose : Low-level functions for using printf() via RTT in IAR.
  61. To use RTT for printf output, include this file in your
  62. application and set the Library Configuration to Normal.
  63. Revision: $Rev: 4351 $
  64. ----------------------------------------------------------------------
  65. */
  66. #include "sdk_config.h"
  67. #if !defined(RETARGET_ENABLED) || RETARGET_ENABLED == 0
  68. #ifdef __IAR_SYSTEMS_ICC__
  69. #include <yfuns.h>
  70. #include "SEGGER_RTT.h"
  71. #pragma module_name = "?__write"
  72. /*********************************************************************
  73. *
  74. * Function prototypes
  75. *
  76. **********************************************************************
  77. */
  78. size_t __write(int handle, const unsigned char * buffer, size_t size);
  79. /*********************************************************************
  80. *
  81. * Global functions
  82. *
  83. **********************************************************************
  84. */
  85. /*********************************************************************
  86. *
  87. * __write()
  88. *
  89. * Function description
  90. * Low-level write function.
  91. * Standard library subroutines will use this system routine
  92. * for output to all files, including stdout.
  93. * Write data via RTT.
  94. */
  95. size_t __write(int handle, const unsigned char * buffer, size_t size) {
  96. (void) handle; /* Not used, avoid warning */
  97. SEGGER_RTT_Write(0, (const char*)buffer, size);
  98. return size;
  99. }
  100. /*********************************************************************
  101. *
  102. * __write_buffered()
  103. *
  104. * Function description
  105. * Low-level write function.
  106. * Standard library subroutines will use this system routine
  107. * for output to all files, including stdout.
  108. * Write data via RTT.
  109. */
  110. size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) {
  111. (void) handle; /* Not used, avoid warning */
  112. SEGGER_RTT_Write(0, (const char*)buffer, size);
  113. return size;
  114. }
  115. #endif // #ifdef __IAR_SYSTEMS_ICC__
  116. #endif // #if !defined(RETARGET_ENABLED) || RETARGET_ENABLED == 0
  117. /****** End Of File *************************************************/