Skip to content

Commit 482dd59

Browse files
Abilty to limit iterations in hci processing loop (#1998)
Fixes #1455
1 parent b122c42 commit 482dd59

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/rp2_common/pico_cyw43_driver/btstack_hci_transport_cyw43.c

Lines changed: 9 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,12 @@ 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, limit the max number of iterations of the hci processing loop, type=int, advanced=true, group=pico_btstack
155+
#ifdef PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT
156+
if (++loop_count >= PICO_BTSTACK_CYW43_MAX_HCI_PROCESS_LOOP_COUNT) {
157+
break;
158+
}
159+
#endif
151160
} while (has_work);
152161
}
153162

0 commit comments

Comments
 (0)