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 
28 /** @addtogroup STM32MP1xx_log
29   * @{
30   */
31 
32 /** @addtogroup STM32MP1xx_Log_Private_Includes
33   * @{
34   */
35 #include "openamp_log.h"
36 /**
37   * @}
38   */
39 
40 /** @addtogroup STM32MP1xx_Log_Private_TypesDefinitions
41   * @{
42   */
43 
44 /**
45   * @}
46   */
47 
48 /** @addtogroup STM32MP1xx_Log_Private_Defines
49   * @{
50   */
51 
52 /**
53   * @}
54   */
55 
56 #if defined (__LOG_TRACE_IO_)
57 char system_log_buf[SYSTEM_TRACE_BUF_SZ];
58 
log_buff(int ch)59 __weak void log_buff(int ch)
60 {
61   /* Place your implementation of fputc here */
62   /* e.g. write a character to the USART1 and Loop until the end of transmission */
63  static int offset = 0;
64 
65 	if (offset + 1 >= SYSTEM_TRACE_BUF_SZ)
66 		offset = 0;
67 
68 	system_log_buf[offset] = ch;
69 	system_log_buf[offset++ + 1] = '\0';
70 }
71 
72 #endif
73 
74 #if defined ( __CC_ARM) || (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
75 #define PUTCHAR_PROTOTYPE int stdout_putchar(int ch)
76 #elif __GNUC__
77 /* With GCC/RAISONANCE, small log_info (option LD Linker->Libraries->Small log_info
78    set to 'Yes') calls __io_putchar() */
79 #define PUTCHAR_PROTOTYPE int __attribute__(( weak )) __io_putchar(int ch)
80 #else
81 #define PUTCHAR_PROTOTYPE int __attribute__(( weak )) fputc(int ch, FILE *f)
82 #endif /* __GNUC__ */
83 
84 #if defined (__LOG_UART_IO_) || defined (__LOG_TRACE_IO_)
85 PUTCHAR_PROTOTYPE
86 {
87   /* Place your implementation of fputc here */
88   /* e.g. write a character to the USART1 and Loop until the end of transmission */
89 #if defined (__LOG_UART_IO_)
90 extern UART_HandleTypeDef huart;
91   HAL_UART_Transmit(&huart, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
92 #endif
93 #if defined (__LOG_TRACE_IO_)
94 	log_buff(ch);
95 #endif
96 	return ch;
97 }
98 #else
99 /* No printf output */
100 #endif
101 
102 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
103