Skip to content

Commit

Permalink
drivers: wifi: esp_at: Fix serial receive interrupt can't exit
Browse files Browse the repository at this point in the history
If a character is received immediately after modem_iface_uart_init called,
the modem_iface_uart_isr function will not read the data in the serial port
fifo register as the context has not been registered at this time,
which will result in the program not being able to exit the interrupt,
so the context should registered before the serial port is initialised.

Signed-off-by: Hongquan Li <[email protected]>
  • Loading branch information
hongquan-prog committed Nov 3, 2024
1 parent e90c58a commit 5d3bb74
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/wifi/esp_at/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,14 @@ static int esp_init(const struct device *dev)
.hw_flow_control = DT_PROP(ESP_BUS, hw_flow_control),
};

/* The context must be registered before the serial port is initialised. */
data->mctx.driver_data = data;
ret = modem_context_register(&data->mctx);
if (ret < 0) {
LOG_ERR("Error registering modem context: %d", ret);
goto error;
}

ret = modem_iface_uart_init(&data->mctx.iface, &data->iface_data, &uart_config);
if (ret < 0) {
goto error;
Expand All @@ -1627,14 +1635,6 @@ static int esp_init(const struct device *dev)
}
#endif

data->mctx.driver_data = data;

ret = modem_context_register(&data->mctx);
if (ret < 0) {
LOG_ERR("Error registering modem context: %d", ret);
goto error;
}

/* start RX thread */
k_thread_create(&esp_rx_thread, esp_rx_stack,
K_KERNEL_STACK_SIZEOF(esp_rx_stack),
Expand Down

0 comments on commit 5d3bb74

Please sign in to comment.