drivers: wifi: esp_at: Fix serial receive interrupt can't exit

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 <hongquan.prog@gmail.com>
This commit is contained in:
Hongquan Li 2024-10-28 16:44:43 +08:00 committed by Henrik Brix Andersen
commit 41e33573e8

View file

@ -1606,6 +1606,14 @@ static int esp_init(const struct device *dev)
.hw_flow_control = DT_PROP(ESP_BUS, hw_flow_control), .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); ret = modem_iface_uart_init(&data->mctx.iface, &data->iface_data, &uart_config);
if (ret < 0) { if (ret < 0) {
goto error; goto error;
@ -1627,14 +1635,6 @@ static int esp_init(const struct device *dev)
} }
#endif #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 */ /* start RX thread */
k_thread_create(&esp_rx_thread, esp_rx_stack, k_thread_create(&esp_rx_thread, esp_rx_stack,
K_KERNEL_STACK_SIZEOF(esp_rx_stack), K_KERNEL_STACK_SIZEOF(esp_rx_stack),