drivers/esp-hosted: Replace EVENT_POLL_HOOK with mp_event_wait_ms.
Signed-off-by: Andrew Leech <andrew@alelec.net>
This commit is contained in:
committed by
Damien George
parent
573180f788
commit
cfcc53da72
@@ -72,7 +72,7 @@ int esp_hosted_hci_cmd(int ogf, int ocf, size_t param_len, const uint8_t *param_
|
|||||||
// Receive HCI event packet, initially reading 3 bytes (HCI Event, Event code, Plen).
|
// Receive HCI event packet, initially reading 3 bytes (HCI Event, Event code, Plen).
|
||||||
for (mp_uint_t start = mp_hal_ticks_ms(), size = 3, i = 0; i < size;) {
|
for (mp_uint_t start = mp_hal_ticks_ms(), size = 3, i = 0; i < size;) {
|
||||||
while (!mp_bluetooth_hci_uart_any()) {
|
while (!mp_bluetooth_hci_uart_any()) {
|
||||||
MICROPY_EVENT_POLL_HOOK
|
mp_event_wait_ms(1);
|
||||||
// Timeout.
|
// Timeout.
|
||||||
if ((mp_hal_ticks_ms() - start) > HCI_COMMAND_TIMEOUT) {
|
if ((mp_hal_ticks_ms() - start) > HCI_COMMAND_TIMEOUT) {
|
||||||
error_printf("timeout waiting for HCI packet\n");
|
error_printf("timeout waiting for HCI packet\n");
|
||||||
@@ -126,7 +126,7 @@ int mp_bluetooth_hci_controller_init(void) {
|
|||||||
if (mp_bluetooth_hci_uart_any()) {
|
if (mp_bluetooth_hci_uart_any()) {
|
||||||
mp_bluetooth_hci_uart_readchar();
|
mp_bluetooth_hci_uart_readchar();
|
||||||
}
|
}
|
||||||
MICROPY_EVENT_POLL_HOOK
|
mp_event_wait_ms(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY
|
#ifdef MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ static int esp_hosted_request(CtrlMsgId msg_id, void *ctrl_payload) {
|
|||||||
|
|
||||||
static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
|
static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
|
||||||
CtrlMsg *ctrl_msg = NULL;
|
CtrlMsg *ctrl_msg = NULL;
|
||||||
for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_hal_delay_ms(10)) {
|
for (mp_uint_t start = mp_hal_ticks_ms(); ; mp_event_wait_ms(10)) {
|
||||||
if (!esp_hosted_stack_empty(&esp_state.stack)) {
|
if (!esp_hosted_stack_empty(&esp_state.stack)) {
|
||||||
ctrl_msg = esp_hosted_stack_pop(&esp_state.stack, true);
|
ctrl_msg = esp_hosted_stack_pop(&esp_state.stack, true);
|
||||||
if (ctrl_msg->msg_id == msg_id) {
|
if (ctrl_msg->msg_id == msg_id) {
|
||||||
@@ -264,8 +264,6 @@ static CtrlMsg *esp_hosted_response(CtrlMsgId msg_id, uint32_t timeout) {
|
|||||||
if ((mp_hal_ticks_ms() - start) >= timeout) {
|
if ((mp_hal_ticks_ms() - start) >= timeout) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MICROPY_EVENT_POLL_HOOK
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If message type is a response, check the response struct's return value.
|
// If message type is a response, check the response struct's return value.
|
||||||
|
|||||||
Reference in New Issue
Block a user