mikroSDK Reference Manual
log.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
39
43#ifndef _API_LOG_LOG_H_
44#define _API_LOG_LOG_H_
45
46#ifdef __cplusplus
47extern "C"{
48#endif
49
50#include "plot.h"
51#include "drv_uart.h"
52#include <stdarg.h>
53
65typedef enum
66{
67 LOG_LEVEL_DEBUG = 0x00,
68 LOG_LEVEL_INFO = 0x01,
69 LOG_LEVEL_WARNING = 0x02,
70 LOG_LEVEL_ERROR = 0x03,
71 LOG_LEVEL_FATAL = 0x04
73
77typedef struct
78{
79 uart_t uart;
80 log_level_t log_level;
81} log_t;
82
86typedef struct
87{
88 hal_pin_name_t rx_pin;
89 hal_pin_name_t tx_pin;
90 uint32_t baud;
91 log_level_t level;
92} log_cfg_t;
93
105#define LOG_MAP_USB_UART(cfg) \
106 cfg.rx_pin = USB_UART_RX; \
107 cfg.tx_pin = USB_UART_TX; \
108 cfg.baud = 115200; \
109 cfg.level = LOG_LEVEL_DEBUG;
110
114#define LOG_MAP_MIKROBUS(cfg, mikrobus) \
115 cfg.rx_pin = MIKROBUS(mikrobus, MIKROBUS_RX); \
116 cfg.tx_pin = MIKROBUS(mikrobus, MIKROBUS_TX); \
117 cfg.baud = 115200; \
118 cfg.level = LOG_LEVEL_DEBUG;
119
129void log_init ( log_t *log, log_cfg_t *cfg );
130
140void log_printf ( log_t *log, const code char * __generic_ptr f,... );
141
147void log_clear ( log_t *log );
148
159int8_t log_read ( log_t *log, uint8_t *rx_data_buf, uint8_t max_len );
160
171void log_info ( log_t *log, const code char * __generic_ptr f,... );
172
183void log_error ( log_t *log, const code char * __generic_ptr f,... );
184
195void log_fatal ( log_t *log, const code char * __generic_ptr f,... );
196
207void log_debug ( log_t *log, const code char * __generic_ptr f,... );
208
219void log_warning ( log_t *log, const code char * __generic_ptr f,... );
220
232void log_log ( log_t *log, char * prefix, const code char * __generic_ptr f, ... );
233
234 // loggroup
235 // apigroup
236
237#ifdef __cplusplus
238}
239#endif
240#endif // _API_LOG_LOG_H_
241// ------------------------------------------------------------------------- END
API for UART driver.
void log_warning(log_t *log, const code char *__generic_ptr f,...)
WARNING printf function.
void log_printf(log_t *log, const code char *__generic_ptr f,...)
Printf function.
void log_error(log_t *log, const code char *__generic_ptr f,...)
ERROR printf function.
void log_debug(log_t *log, const code char *__generic_ptr f,...)
DEBUG printf function.
void log_log(log_t *log, char *prefix, const code char *__generic_ptr f,...)
Printf function with a variable prefix.
void log_init(log_t *log, log_cfg_t *cfg)
Initializes LOG module.
log_level_t
Log level values.
Definition log.h:66
void log_info(log_t *log, const code char *__generic_ptr f,...)
INFO printf function.
void log_clear(log_t *log)
Empty wrapper API.
void log_fatal(log_t *log, const code char *__generic_ptr f,...)
FATAL printf function.
int8_t log_read(log_t *log, uint8_t *rx_data_buf, uint8_t max_len)
Empty wrapper API.
hal_ll_pin_name_t hal_pin_name_t
Definition hal_target.h:60
Implements plot functionality.
LOG init configuration structure.
Definition log.h:84
LOG context structure.
Definition log.h:76
UART driver context structure, consisted of the following fields :
Definition drv_uart.h:165