zephyr/subsys/bluetooth/controller/hal/debug.h
Morten Priess ef7ddc07d3 Bluetooth: controller: Implement macros for vendor assert information
Implement LL_ASSERT_INFO1 and LL_ASSERT_INFO2 for triggering assertions
with parameter information provided for vendor core dump.

Adds Kconfig CONFIG_BT_CTLR_ASSERT_VENDOR by which the new LL asserts
map to BT_ASSERT_VND macros, which shall be implemented in the
debug_vendor_hal.h of the platform. If not enabled, LL_ASSERT_INFO will
map to existing BT_ASSERT_MSG with parameters printed.

Add use of LL_ASSERT_INFO2 where ull_ticker_stop_with_mark() result may
assert.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-08 15:03:08 -05:00

50 lines
1.5 KiB
C

/*
* Copyright (c) 2016 Nordic Semiconductor ASA
* Copyright (c) 2016 Vinayak Kariappa Chettimada
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "common/assert.h"
#ifdef CONFIG_BT_CTLR_ASSERT_HANDLER
void bt_ctlr_assert_handle(char *file, uint32_t line);
#define LL_ASSERT(cond) \
if (!(cond)) { \
BT_ASSERT_PRINT(cond); \
bt_ctlr_assert_handle(__FILE__, __LINE__); \
}
#define LL_ASSERT_MSG(cond, fmt, ...) \
if (!(cond)) { \
BT_ASSERT_PRINT(cond); \
BT_ASSERT_PRINT_MSG(fmt, ##__VA_ARGS__); \
bt_ctlr_assert_handle(__FILE__, __LINE__); \
}
#else
#define LL_ASSERT(cond) \
BT_ASSERT(cond)
#define LL_ASSERT_MSG(cond, fmt, ...) \
BT_ASSERT_MSG(cond, fmt, ##__VA_ARGS__)
#endif
#if defined(CONFIG_BT_CTLR_ASSERT_VENDOR)
#define LL_ASSERT_INFO1(cond, param) \
BT_ASSERT_VND(cond, param, 0)
#define LL_ASSERT_INFO2(cond, param1, param2) \
BT_ASSERT_VND(cond, param1, param2)
#else
#define LL_ASSERT_INFO1(cond, param) \
LL_ASSERT_MSG(cond, "param: %u", param)
#define LL_ASSERT_INFO2(cond, param1, param2) \
LL_ASSERT_MSG(cond, "param1: %u param2: %u", param1, param2)
#endif /* CONFIG_BT_CTLR_ASSERT_VENDOR */
#if defined(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START)
#define LL_ASSERT_OVERHEAD(overhead) \
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u", \
__func__, HAL_TICKER_TICKS_TO_US(overhead));
#else /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
#define LL_ASSERT_OVERHEAD(overhead) ARG_UNUSED(overhead)
#endif /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
#include "hal/debug_vendor_hal.h"