Skip to content

Commit 41e3357

Browse files
hongquan-proghenrikbrixandersen
authored andcommitted
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 <[email protected]>
1 parent 53ae195 commit 41e3357

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/wifi/esp_at/esp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,14 @@ static int esp_init(const struct device *dev)
16061606
.hw_flow_control = DT_PROP(ESP_BUS, hw_flow_control),
16071607
};
16081608

1609+
/* The context must be registered before the serial port is initialised. */
1610+
data->mctx.driver_data = data;
1611+
ret = modem_context_register(&data->mctx);
1612+
if (ret < 0) {
1613+
LOG_ERR("Error registering modem context: %d", ret);
1614+
goto error;
1615+
}
1616+
16091617
ret = modem_iface_uart_init(&data->mctx.iface, &data->iface_data, &uart_config);
16101618
if (ret < 0) {
16111619
goto error;
@@ -1627,14 +1635,6 @@ static int esp_init(const struct device *dev)
16271635
}
16281636
#endif
16291637

1630-
data->mctx.driver_data = data;
1631-
1632-
ret = modem_context_register(&data->mctx);
1633-
if (ret < 0) {
1634-
LOG_ERR("Error registering modem context: %d", ret);
1635-
goto error;
1636-
}
1637-
16381638
/* start RX thread */
16391639
k_thread_create(&esp_rx_thread, esp_rx_stack,
16401640
K_KERNEL_STACK_SIZEOF(esp_rx_stack),

0 commit comments

Comments
 (0)