• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description:   LOG UART MODULE INTERFACE
15  * Author:
16  * Create:
17  */
18 
19 #ifndef LOG_UART_H
20 #define LOG_UART_H
21 
22 /**
23  * @addtogroup connectivity_libs_log_reader
24  * @{
25  */
26 #if defined USE_CMSIS_OS
27 
28 #include "log_memory_definitions.h"
29 #include "log_oam_msg.h"
30 
31 #define LOG_UART_LOG_WATERMARK_VALUE_ON_INIT    0
32 #define LOG_UART_BT_LOG_WATERMARK_VALUE_HIGH    ((BT_CORE_LOGGING_LENGTH)*8 / 10)
33 
34 typedef enum {
35     NXLOG_OPERATION_ENABLE = 0,
36     NXLOG_OPERATION_DISABLE,
37     NXLOG_OPERATION_DELETE,
38     NXLOG_OPERATION_DUMP_TO_AT_UART,
39     NXLOG_OPERATION_DUMP_TO_DEBUG_UART,
40 } nxlog_operation_t;
41 
42 #if SYS_DEBUG_MODE_ENABLE == YES
43 void log_register_default_rx_callback(void);
44 #endif  /* end of SYS_DEBUG_MODE_ENABLE == YES */
45 
46 /**
47  * @brief  Initialises the uart logger before RTOS functions are available.
48  */
49 void log_uart_init(void);
50 
51 /**
52  * @brief  Send buffer used log uart by write uart tx FIFO
53  */
54 void log_uart_send_buffer(const uint8_t *buffer, uint16_t length);
55 /**
56  * @brief  Send buffer used log uart by write uart tx FIFO
57  */
58 void log_uart_write_blocking(const void *buf, uint32_t len);
59 
60 /**
61  * @brief  output response to at uart callback
62  * @param  at_string The at string to send out through at uart.
63  */
64 typedef void (*log_uart_output_response_to_at_uart_callback)(const char *at_string, uint16_t len);
65 
66 /**
67  * @brief  Initialises the UART logging when RTOS functions are available.
68  * This should be called before the RTOS scheduler starts, but when we can create mutexes.
69  */
70 void log_uart_init_after_rtos(void);
71 
72 /**
73  * @brief  Triggers the uart logger.
74  * It can be called from program context or ISR.
75  */
76 void log_uart_trigger(void);
77 
78 /**
79  * @brief  Check if the xlog is enabled.
80  * @return 1 if the xlog is enabled.
81  */
82 uint32_t log_uart_get_nxlog_state(void);
83 
84 /**
85  * @brief  Reconfigure the baud rate when the frequency changes.
86  */
87 void log_uart_reset_baud_rate(void);
88 
89 /**
90  * @brief  Main log uart task
91  * @param  unused_p unused parameter
92  */
93 void log_main(const void *unused_p);
94 
95 /**
96  * @brief  Update the watermark level for a given logging region.
97  * @note   Currently just LOG_MEMORY_REGION_SECTION_1 is supported.
98  */
99 void log_uart_update_watermark_level(log_memory_region_section_t log_mem_region, uint16_t new_watermark_val);
100 
101 #if (CORE_NUMS > 1) && (defined CONFIG_DFX_SUPPORT_CUSTOM_LOG) && (defined DFX_YES) && \
102     (CONFIG_DFX_SUPPORT_CUSTOM_LOG == DFX_YES)
103 /**
104  * @brief  Handler for informing LOG thread to send log contents.
105  */
106 void log_reader_info_action_handler(void);
107 #endif
108 
109 #else
110 #error "log to uart not implemented in non-os version"
111 #endif  // defined USE_CMSIS_OS
112 
113 /**
114  * @}
115  */
116 #endif
117