Bluetooth: Controller: Use BT_ASSERT instead of custom impl.

As part of closer integration into Zephyr, remove the use
of custom assert mechanism and use BT_ASSERT instead.

Jira: ZEP-761

Change-id: I27f37d697b0a84bc001754a8d0b4dbb6ddb54298
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This commit is contained in:
Vinayak Chettimada 2016-09-08 18:08:58 +02:00 committed by Johan Hedberg
commit e00eed79aa
10 changed files with 192 additions and 215 deletions

View file

@ -92,14 +92,14 @@ hf_start_return:
/* rollover should not happen as start and stop shall be
* called in pairs.
*/
ASSERT(clock_instance.m16src_refcount);
BT_ASSERT(clock_instance.m16src_refcount);
return (((NRF_CLOCK->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk)) ? 1 : 0);
}
void clock_m16src_stop(void)
{
ASSERT(clock_instance.m16src_refcount);
BT_ASSERT(clock_instance.m16src_refcount);
if (--clock_instance.m16src_refcount) {
return;
@ -183,7 +183,7 @@ void power_clock_isr(void)
done = (NRF_CLOCK->EVENTS_DONE != 0);
ctto = (NRF_CLOCK->EVENTS_CTTO != 0);
ASSERT(pof || hf || lf || done || ctto);
BT_ASSERT(pof || hf || lf || done || ctto);
if (pof) {
NRF_POWER->EVENTS_POFWARN = 0;
@ -203,7 +203,7 @@ void power_clock_isr(void)
if (lf) {
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
ASSERT(0);
BT_ASSERT(0);
}
if (done) {

View file

@ -18,30 +18,13 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
#ifdef __GNUC__
#define ASSERT(x) do { \
if (!(x)) { \
__asm__ volatile (".inst 0xde00\n"); \
} \
} while (0)
#else
static __asm void _udf(void)
{
UND #0;
}
#include <bluetooth/log.h>
#define ASSERT(x) do { \
if (!(x)) { \
_udf(); \
} \
} while (0)
#endif
#if (DEBUG == 1)
/*
* P2 is outgoing debug pins.
* Debug pins are initialized to low.
/* below are some interesting macros referenced by controller
* which can be defined to SoC's GPIO toggle to observe/debug the
* controller's runtime behavior.
*/
#if (DEBUG == 1)
#define DEBUG_INIT() do { \
NRF_GPIO->DIRSET = 0x03FF0000; \
NRF_GPIO->OUTCLR = 0x03FF0000; } \

View file

@ -125,7 +125,7 @@ void ecb_isr(void)
}
else {
ASSERT(0);
BT_ASSERT(0);
}
}

View file

@ -483,7 +483,7 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt)
NRF_CCM->INTENCLR = CCM_INTENCLR_ENDCRYPT_Msk;
NVIC_ClearPendingIRQ(CCM_AAR_IRQn);
ASSERT(NRF_CCM->EVENTS_ERROR == 0);
BT_ASSERT(NRF_CCM->EVENTS_ERROR == 0);
#else
/* start KSGEN early, but dont wait for ENDCRYPT */
NRF_CCM->TASKS_KSGEN = 1;

View file

@ -33,7 +33,7 @@ static struct rand *_rand;
void rand_init(uint8_t *context, uint8_t context_len)
{
ASSERT(context_len > sizeof(struct rand));
BT_ASSERT(context_len > sizeof(struct rand));
_rand = (struct rand *)context;
_rand->count = context_len - sizeof(struct rand) + 1;

View file

@ -46,7 +46,7 @@ uint32_t rtc_start(void)
uint32_t rtc_stop(void)
{
ASSERT(_rtc_refcount);
BT_ASSERT(_rtc_refcount);
if (--_rtc_refcount) {
return 1;

View file

@ -1021,7 +1021,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
break;
case HCI_OCF_LE_SET_ADV_PARAMS:
ll_adv_params_set(cmd->params.le_set_adv_params.interval_min,
c_adv_type[cmd->params.le_set_adv_params.type],
cmd->params.le_set_adv_params.own_addr_type,
@ -1146,7 +1145,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
break;
case HCI_OCF_LE_CLEAR_WHITELIST:
radio_filter_clear();
evt->code = HCI_EVT_CODE_COMMAND_COMPLETE;
@ -1156,7 +1154,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
break;
case HCI_OCF_LE_ADD_DEVICE_TO_WHITELIST:
error_code = radio_filter_add(cmd->params.le_add_dev_to_wlist.
addr_type,
&cmd->params.le_add_dev_to_wlist.addr[0]);
@ -1171,9 +1168,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
break;
case HCI_OCF_LE_CONNECTION_UPDATE:
/** @todo if peer supports LE Conn Param Req,
* use Req cmd (1) instead of Initiate cmd (0).
*/
status = radio_conn_update(cmd->params.le_conn_update.handle,
0, 0,
cmd->params.le_conn_update.
@ -1310,8 +1304,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
case HCI_OCF_LE_REMOTE_CONN_PARAM_REQ_NEG_REPLY:
le_cp_req_neg_rep =
&cmd->params.le_remote_conn_param_req_neg_reply;
/** @todo add reject_ext_ind support in ctrl.c */
ASSERT(0);
status = radio_conn_update(le_cp_req_neg_rep->handle, 2,
le_cp_req_neg_rep->reason, 0, 0, 0);
@ -1328,9 +1320,6 @@ static int controller_cmd_handle(uint8_t ocf, struct hci_cmd *cmd, uint8_t *len,
break;
case HCI_OCF_LE_SET_DATA_LENGTH:
/** @todo add reject_ext_ind support in ctrl.c */
ASSERT(0);
status = radio_length_req_send(
cmd->params.le_set_data_length.handle,
cmd->params.le_set_data_length.tx_octets);
@ -1710,7 +1699,7 @@ static void encode_control(uint8_t *buf, uint8_t *len, uint8_t **out)
break;
default:
ASSERT(0);
BT_ASSERT(0);
break;
}
}
@ -1893,7 +1882,7 @@ static void encode_data_ctrl(struct radio_pdu_node_rx *radio_pdu_node_rx,
break;
default:
ASSERT(0);
BT_ASSERT(0);
break;
}
@ -1935,13 +1924,13 @@ static void encode_data(uint8_t *buf, uint8_t *len, uint8_t **out)
if (s_rx_cnt != pdu_data->payload.lldata[0]) {
s_rx_cnt = pdu_data->payload.lldata[0];
ASSERT(0);
BT_ASSERT(0);
} else {
uint8_t index;
for (index = 0; index < pdu_data->len; index++) {
ASSERT(pdu_data->payload.lldata[index] ==
(uint8_t)(s_rx_cnt + index))
BT_ASSERT(pdu_data->payload.lldata[index] ==
(uint8_t)(s_rx_cnt + index));
}
s_rx_cnt++;
@ -1954,7 +1943,7 @@ static void encode_data(uint8_t *buf, uint8_t *len, uint8_t **out)
break;
default:
ASSERT(0);
BT_ASSERT(0);
break;
}

File diff suppressed because it is too large Load diff

View file

@ -1053,7 +1053,8 @@ static inline void ticker_job_compare_update(
do {
uint32_t ticks_elapsed;
ASSERT(i--);
BT_ASSERT(i);
i--;
ctr = rtc_tick_get();
cc = instance->ticks_current;

View file

@ -225,10 +225,10 @@ static void native_recv_fiber(int unused0, int unused1)
int retval;
hci_encode_num_cmplt(handle, num_cmplt, &len, &buf);
ASSERT(len);
BT_ASSERT(len);
retval = native_recv(len, buf);
ASSERT(!retval);
BT_ASSERT(!retval);
fiber_yield();
}
@ -245,7 +245,7 @@ static void native_recv_fiber(int unused0, int unused1)
*/
if (len) {
retval = native_recv(len, buf);
ASSERT(!retval);
BT_ASSERT(!retval);
}
radio_rx_dequeue();