rp2/mpbthciport: Cancel existing alarms.

Cancel any existing poll alarm before add a new one.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Peter Harper 2023-03-13 10:35:48 +00:00 committed by Damien George
parent 888a15cda3
commit a459eaf3e6
1 changed files with 3 additions and 0 deletions

View File

@ -57,6 +57,9 @@ static int64_t mp_bluetooth_hci_timer_callback(alarm_id_t id, void *user_data) {
}
void mp_bluetooth_hci_poll_in_ms(uint32_t ms) {
if (poll_timer_id != 0) {
cancel_alarm(poll_timer_id);
}
poll_timer_id = add_alarm_in_ms(ms, mp_bluetooth_hci_timer_callback, NULL, true);
}