• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved.
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  */
15 
16 #ifndef _LEGA_DBG_H_
17 #define _LEGA_DBG_H_
18 
19 #include <stdio.h>
20 #include "lega_types.h"
21 
22 #define D_CRT       1
23 #define D_ERR       2
24 #define D_WRN       3
25 #define D_INF       4
26 #define D_DBG       5
27 
28 #define D_LWIFI_KE        BIT(0)
29 #define D_LWIFI_DMA       BIT(1)
30 #define D_LWIFI_MM        BIT(2)
31 #define D_LWIFI_TX        BIT(3)
32 #define D_LWIFI_RX        BIT(4)
33 #define D_LWIFI_PHY       BIT(5)
34 #define D_LWIFI           BIT(6)
35 
36 #define D_UWIFI_DATA      BIT(11)
37 #define D_UWIFI_CTRL      BIT(12)
38 #define D_UWIFI_SUPP      BIT(13)
39 
40 #define D_OS              BIT(14)
41 #define D_LWIP            BIT(15)
42 
43 #define D_AT              BIT(16)
44 
45 #define LWIFI_COMP        (D_LWIFI_KE | D_LWIFI_DMA | D_LWIFI_MM | \
46                            D_LWIFI_TX | D_LWIFI_RX | D_LWIFI_PHY | D_LWIFI)
47 #define UWIFI_COMP        (D_UWIFI_DATA | D_UWIFI_CTRL | D_UWIFI_SUPP)
48 #define OS_COMP           (D_OS)
49 #define LWIP_COMP         (D_LWIP)
50 #define AT_COMP           (D_AT)
51 
52 extern uint32_t  GlobalDebugComponents;
53 extern uint32_t  GlobalDebugLevel;
54 extern uint8_t   GlobalDebugEn;
55 extern uint32_t lega_rtos_get_time(void);
56 extern char *component_info(uint32_t module_t);
57 
58 #define component_t(module_t) component_info(module_t)
59 
60 #define dbg(Level, Comp, Fmt, ...) \
61     do {\
62         if(GlobalDebugEn && (Comp & GlobalDebugComponents) && (Level <= GlobalDebugLevel)) {\
63             printf("[%u] ",(unsigned int)lega_rtos_get_time());\
64             printf(Fmt "\r\n", ## __VA_ARGS__);\
65         }\
66     } while (0)
67 
68 #endif // _LEGA_DBG_H_
69