Mistake on this page?
Report an issue in GitHub or email us
whd_debug.h
1 /*
2  * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <stdio.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include "whd.h"
22 
23 #ifndef INCLUDED_WHD_DEBUG_H
24 #define INCLUDED_WHD_DEBUG_H
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 /******************************************************
32 * Macros
33 ******************************************************/
34 #define WPRINT_ENABLE_WHD_ERROR
35 /* #define WPRINT_ENABLE_WHD_INFO */
36 /* #define WPRINT_ENABLE_WHD_DEBUG */
37 
38 #define WHD_ENABLE_STATS
39 /*#define WHD_LOGGING_BUFFER_ENABLE*/
40 
41 #if defined (__GNUC__)
42 #define WHD_TRIGGER_BREAKPOINT( ) do { __asm__ ("bkpt"); } while (0)
43 
44 #elif defined (__IAR_SYSTEMS_ICC__)
45 #define WHD_TRIGGER_BREAKPOINT( ) do { __asm("bkpt 0"); } while (0)
46 
47 #else
48 #define WHD_TRIGGER_BREAKPOINT( )
49 #endif
50 
51 #ifdef WPRINT_ENABLE_ERROR
52 #define WPRINT_ERROR(args) do { WPRINT_MACRO(args); } while (0)
53 #define whd_assert(error_string, assertion) do { if (!(assertion) ){ WHD_TRIGGER_BREAKPOINT(); } } while (0)
54 #define whd_minor_assert(error_string, \
55  assertion) do { if (!(assertion) ) WPRINT_MACRO( (error_string) ); } while (0)
56 #else
57 #define whd_assert(error_string, \
58  assertion) do { if (!(assertion) ){ WPRINT_MACRO( (error_string) ); } } while (0)
59 #define whd_minor_assert(error_string, assertion) do { (void)(assertion); } while (0)
60 #endif
61 
62 /******************************************************
63 * Print declarations
64 ******************************************************/
65 /* IF MFG TEST is enabled then disable all LOGGING VIA UART as
66  + * this interrupts communication between WL TOOL and MFG Test APP
67  + * via STDIO UART causing Wrong Message Exchange and failure.
68  + */
69 #if defined(WLAN_MFG_FIRMWARE) || defined(WHD_PRINT_DISABLE)
70 #define WPRINT_MACRO(args)
71 #else
72 #if defined(WHD_LOGGING_BUFFER_ENABLE)
73 #define WPRINT_MACRO(args) do { whd_buffer_printf args; } while (0 == 1)
74 #else
75 #define WPRINT_MACRO(args) do { printf args;} while (0 == 1)
76 #endif
77 #endif
78 
79 
80 /* WICED printing macros for Wiced Wi-Fi Driver*/
81 #ifdef WPRINT_ENABLE_WHD_INFO
82 #define WPRINT_WHD_INFO(args) WPRINT_MACRO(args)
83 #else
84 #define WPRINT_WHD_INFO(args)
85 #endif
86 
87 #ifdef WPRINT_ENABLE_WHD_DEBUG
88 #define WPRINT_WHD_DEBUG(args) WPRINT_MACRO(args)
89 #else
90 #define WPRINT_WHD_DEBUG(args)
91 #endif
92 
93 #ifdef WPRINT_ENABLE_WHD_ERROR
94 #define WPRINT_WHD_ERROR(args) WPRINT_MACRO(args);
95 #else
96 #define WPRINT_WHD_ERROR(args)
97 #endif
98 
99 #ifdef WPRINT_ENABLE_WHD_DATA_LOG
100 #define WPRINT_WHD_DATA_LOG(args) WPRINT_MACRO(args)
101 #else
102 #define WPRINT_WHD_DATA_LOG(args)
103 #endif
104 
105 #define WHD_STATS_INCREMENT_VARIABLE(whd_driver, var) \
106  do { whd_driver->whd_stats.var++; } while (0)
107 
108 #define WHD_STATS_CONDITIONAL_INCREMENT_VARIABLE(whd_driver, condition, var) \
109  do { if (condition){ whd_driver->whd_stats.var++; }} while (0)
110 
111 #if (defined(__GNUC__) && (__GNUC__ >= 6) )
112 #define __FUNCTION__ __func__
113 #endif
114 
115 
116 void whd_init_stats(whd_driver_t whd_driver);
117 void whd_print_logbuffer(void);
118 
119 
120 #ifdef WHD_LOGGING_BUFFER_ENABLE
121 #define LOGGING_BUFFER_SIZE (4 * 1024)
122 int whd_buffer_printf(const char *format, ...);
123 
124 typedef struct
125 {
126  uint32_t buffer_write;
127  uint32_t buffer_read;
128  char buffer[LOGGING_BUFFER_SIZE + 1];
129  whd_bool_t roll_over;
130  whd_bool_t over_write;
131 } whd_logging_t;
132 #else
133 #define whd_print_logbuffer()
134 #endif /* WHD_LOGGING_BUFFER_ENABLE */
135 
136 #ifdef __cplusplus
137 } /* extern "C" */
138 #endif
139 #endif /* ifndef INCLUDED_WHD_DEBUG_H */
140 
Provides abstract pointer type to act as instance for: driver, interface, buffer funcs, network funcs, resource funcs and bus funcs.
whd_bool_t
Boolean values.
Definition: whd_types.h:162
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.