openamp_log.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. ******************************************************************************
  3. * @file log.c
  4. * @author MCD Application Team
  5. * @brief Ressource table
  6. *
  7. * This file provides services for logging
  8. *
  9. ******************************************************************************
  10. *
  11. * @attention
  12. *
  13. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  14. * All rights reserved.</center></h2>
  15. *
  16. * This software component is licensed by ST under BSD 3-Clause license,
  17. * the "License"; You may not use this file except in compliance with the
  18. * License. You may obtain a copy of the License at:
  19. * opensource.org/licenses/BSD-3-Clause
  20. *
  21. *
  22. ******************************************************************************
  23. */
  24. /** @addtogroup LOG
  25. * @{
  26. */
  27. /** @addtogroup STM32MP1xx_log
  28. * @{
  29. */
  30. /** @addtogroup STM32MP1xx_Log_Private_Includes
  31. * @{
  32. */
  33. #include "openamp_log.h"
  34. /**
  35. * @}
  36. */
  37. /** @addtogroup STM32MP1xx_Log_Private_TypesDefinitions
  38. * @{
  39. */
  40. /**
  41. * @}
  42. */
  43. /** @addtogroup STM32MP1xx_Log_Private_Defines
  44. * @{
  45. */
  46. /**
  47. * @}
  48. */
  49. #if defined (__LOG_TRACE_IO_)
  50. char system_log_buf[SYSTEM_TRACE_BUF_SZ];
  51. __weak void log_buff(int ch)
  52. {
  53. /* Place your implementation of fputc here */
  54. /* e.g. write a character to the USART1 and Loop until the end of transmission */
  55. static int offset = 0;
  56. if (offset + 1 >= SYSTEM_TRACE_BUF_SZ)
  57. offset = 0;
  58. system_log_buf[offset] = ch;
  59. system_log_buf[offset++ + 1] = '\0';
  60. }
  61. #endif
  62. #if defined ( __CC_ARM) || (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  63. #define PUTCHAR_PROTOTYPE int stdout_putchar(int ch)
  64. #elif __GNUC__
  65. /* With GCC/RAISONANCE, small log_info (option LD Linker->Libraries->Small log_info
  66. set to 'Yes') calls __io_putchar() */
  67. #define PUTCHAR_PROTOTYPE int __attribute__(( weak )) __io_putchar(int ch)
  68. #else
  69. #define PUTCHAR_PROTOTYPE int __attribute__(( weak )) fputc(int ch, FILE *f)
  70. #endif /* __GNUC__ */
  71. #if defined (__LOG_UART_IO_) || defined (__LOG_TRACE_IO_)
  72. PUTCHAR_PROTOTYPE
  73. {
  74. /* Place your implementation of fputc here */
  75. /* e.g. write a character to the USART1 and Loop until the end of transmission */
  76. #if defined (__LOG_UART_IO_)
  77. extern UART_HandleTypeDef huart;
  78. HAL_UART_Transmit(&huart, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
  79. #endif
  80. #if defined (__LOG_TRACE_IO_)
  81. log_buff(ch);
  82. #endif
  83. return ch;
  84. }
  85. #else
  86. /* No printf output */
  87. #endif
  88. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/