aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include/usbh/debug.h
blob: f90a11a684561184c4c06071be98b6093ee62cd4 (plain)
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
/*
    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
              Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/


#ifndef USBH_DEBUG_H_
#define USBH_DEBUG_H_

#include "hal_usbh.h"

#if HAL_USE_USBH

#if USBH_DEBUG_ENABLE
#if USBH_DEBUG_MULTI_HOST
	/* output callback */
	void USBH_DEBUG_OUTPUT_CALLBACK(USBHDriver *host, const uint8_t *buff, size_t len);

	/* printing functions */
	void usbDbgPrintf(USBHDriver *host, const char *fmt, ...);
	void usbDbgPuts(USBHDriver *host, const char *s);
	void usbDbgInit(USBHDriver *host);
#else
	/* output callback */
	void USBH_DEBUG_OUTPUT_CALLBACK(const uint8_t *buff, size_t len);

	/* printing functions */
	void usbDbgPrintf(const char *fmt, ...);
	void usbDbgPuts(const char *s);
	void usbDbgInit(void);
#endif

	void usbDbgReset(void);
#else

#if USBH_DEBUG_MULTI_HOST
#	define usbDbgPrintf(host, fmt, ...) do {} while(0)
#	define usbDbgPuts(host, s) do {} while(0)
#	define usbDbgInit(host) do {} while(0)
#else
#	define usbDbgPrintf(fmt, ...) do {} while(0)
#	define usbDbgPuts(s) do {} while(0)
#	define usbDbgInit() do {} while(0)
#endif
#	define usbDbgReset() do {} while(0)
#endif

#if USBH_DEBUG_MULTI_HOST
#define _usbh_dbg(host, s) usbDbgPuts(host, s)
#define _usbh_dbgf(host, f, ...) usbDbgPrintf(host, f, ##__VA_ARGS__)
#define _usbh_ldbg(host, lvl, n, s) do {if (lvl >= n) usbDbgPuts(host, s); } while(0)
#define _usbh_ldbgf(host, lvl, n, f, ...) do {if (lvl >= n) usbDbgPrintf(host, f, ##__VA_ARGS__); } while(0)
#else

#define _usbh_dbg(host, s) usbDbgPuts(s)
#define _usbh_dbgf(host, f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
#define _usbh_ldbg(host, lvl, n, s) do {if (lvl >= n) usbDbgPuts(s); } while(0)
#define _usbh_ldbgf(host, lvl, n, f, ...) do {if (lvl >= n) usbDbgPrintf(f, ##__VA_ARGS__); } while(0)

#endif


#endif

#endif /* USBH_DEBUG_H_ */