Skip to content

Commit 9a50132

Browse files
committed
Abilty to limit iterations in hci processing loop
Fixes #1455
1 parent 3708588 commit 9a50132

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/rp2_common/pico_cyw43_driver/btstack_hci_transport_cyw43.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ static void hci_transport_cyw43_process(void) {
139139
CYW43_THREAD_LOCK_CHECK
140140
uint32_t len = 0;
141141
bool has_work;
142+
#ifdef PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT
143+
uint32_t loop_count = 0;
144+
#endif
142145
do {
143146
int err = cyw43_bluetooth_hci_read(hci_packet_with_pre_buffer, sizeof(hci_packet_with_pre_buffer), &len);
144147
BT_DEBUG("bt in len=%lu err=%d\n", len, err);
@@ -148,6 +151,13 @@ static void hci_transport_cyw43_process(void) {
148151
} else {
149152
has_work = false;
150153
}
154+
// PICO_CONFIG: PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT, max number of iterations of the hci processing loop, type=int, default=infinite, advanced=true, group=pico_btstack
155+
#ifdef PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT
156+
loop_count++;
157+
if (loop_count > PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT) {
158+
break;
159+
}
160+
#endif
151161
} while (has_work);
152162
}
153163

0 commit comments

Comments
 (0)