Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "k_log.h"
#include "k_module.h"
#include "k_mem.h"
#include <stdio.h>
#define LOG_DEPTH
Private macros
#define PUTCHAR_PROTOTYPE
#define PUTCHAR_PROTOTYPE
pLOG_CacheBuffer
LOG_IN_ptr
k_LogInit()
__io_putchar(int)
Files
loading...
CodeScopeSTM32 Libraries and SamplesMB1063Core/Src/k_log.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file k_log.c * @author MCD Application Team * @brief This file provides the kernel log functions ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "k_log.h" #include "k_module.h" #include "k_mem.h" #include <stdio.h> /** @addtogroup CORE * @{ *//* ... */ /** @defgroup KERNEL_LOG * @brief Kernel Log routines * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ #define LOG_DEPTH (4 * 512) /* Private macros ------------------------------------------------------------*/ #ifdef __GNUC__ /* With GCC, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() *//* ... */ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) /* ... */#else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif /* __GNUC__ */Private macros /* Private variables ---------------------------------------------------------*/ uint8_t *pLOG_CacheBuffer; uint32_t LOG_IN_ptr = 0; /** * @brief Init Kernel Log * @param None * @retval None *//* ... */ void k_LogInit(void) { pLOG_CacheBuffer = (uint8_t *)k_malloc(LOG_DEPTH); memset (pLOG_CacheBuffer, 0, LOG_DEPTH); LOG_IN_ptr = 0; }{ ... } /** * @brief Redirect printf * @param None * @retval None *//* ... */ PUTCHAR_PROTOTYPE { uint32_t cnt = 0; if( LOG_IN_ptr++ >= LOG_DEPTH) { for (cnt = 1; cnt < LOG_DEPTH; cnt ++) { pLOG_CacheBuffer[cnt -1 ] = pLOG_CacheBuffer[cnt]; }for (cnt = 1; cnt < LOG_DEPTH; cnt ++) { ... } LOG_IN_ptr = LOG_DEPTH; }if (LOG_IN_ptr++ >= LOG_DEPTH) { ... } pLOG_CacheBuffer [LOG_IN_ptr - 1] = ch; if(ch == '\n') { k_UpdateLog ((char *)pLOG_CacheBuffer); }if (ch == '\n') { ... } return ch; ...} /** * @} *//* ... */ /** * @} *//* ... */