1 /*
2  * Copyright (c) 2016 Nordic Semiconductor ASA
3  * Copyright (c) 2016 Vinayak Kariappa Chettimada
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include "common/assert.h"
9 
10 #ifdef CONFIG_BT_CTLR_ASSERT_HANDLER
11 void bt_ctlr_assert_handle(char *file, uint32_t line);
12 #define LL_ASSERT(cond) \
13 		if (!(cond)) { \
14 			BT_ASSERT_PRINT(cond); \
15 			bt_ctlr_assert_handle(__FILE__, __LINE__); \
16 		}
17 #define LL_ASSERT_MSG(cond, fmt, ...) \
18 		if (!(cond)) { \
19 			BT_ASSERT_PRINT(cond); \
20 			BT_ASSERT_PRINT_MSG(fmt, ##__VA_ARGS__); \
21 			bt_ctlr_assert_handle(__FILE__, __LINE__); \
22 		}
23 #else
24 #define LL_ASSERT(cond) \
25 		BT_ASSERT(cond)
26 #define LL_ASSERT_MSG(cond, fmt, ...) \
27 		BT_ASSERT_MSG(cond, fmt, ##__VA_ARGS__)
28 #endif
29 
30 #if defined(CONFIG_BT_CTLR_ASSERT_VENDOR)
31 #define LL_ASSERT_INFO1(cond, param) \
32 		BT_ASSERT_VND(cond, param, 0)
33 #define LL_ASSERT_INFO2(cond, param1, param2) \
34 		BT_ASSERT_VND(cond, param1, param2)
35 #else
36 #define LL_ASSERT_INFO1(cond, param) \
37 		LL_ASSERT_MSG(cond, "param: %u", param)
38 #define LL_ASSERT_INFO2(cond, param1, param2) \
39 		LL_ASSERT_MSG(cond, "param1: %u param2: %u", param1, param2)
40 #endif /* CONFIG_BT_CTLR_ASSERT_VENDOR */
41 
42 #if defined(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START)
43 #define LL_ASSERT_OVERHEAD(overhead) \
44 	LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u", \
45 		      __func__, HAL_TICKER_TICKS_TO_US(overhead));
46 #else /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
47 #define LL_ASSERT_OVERHEAD(overhead) ARG_UNUSED(overhead)
48 #endif /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
49 
50 #include "hal/debug_vendor_hal.h"
51