esp_modem: pppos_client modem to use uart with REF_TICK
pppos_client example used the UART default clock configuration which might
cause issues if power management enabled. Settings updated to UART_SCLK_REF_TICK
Also need to explicitly disable RX interrupts in UART pattern detection
mode.
Closes
@@ -137,6 +137,13 @@ static void esp_handle_uart_pattern(esp_modem_dte_t *esp_dte)
*/
static void esp_handle_uart_data(esp_modem_dte_t *esp_dte)
{
+ if (esp_dte->parent.dce->mode != MODEM_PPP_MODE) {
+ ESP_LOGE(MODEM_TAG, "Error: Got data event in PPP mode");
+ /* pattern detection mode -> ignore date event on uart
+ * (should never happen, but if it does, we could still
+ * read the valid data once pattern detect event fired) */
+ return;
+ }
size_t length = 0;
uart_get_buffered_data_len(esp_dte->uart_port, &length);
length = MIN(ESP_MODEM_LINE_BUFFER_SIZE, length);
@@ -380,7 +387,7 @@ modem_dte_t *esp_modem_dte_init(const esp_modem_dte_config_t *config)
.data_bits = config->data_bits,
.parity = config->parity,
.stop_bits = config->stop_bits,
- .source_clk = UART_SCLK_APB,
+ .source_clk = UART_SCLK_REF_TICK,
.flow_ctrl = (config->flow_control == MODEM_FLOW_CONTROL_HW) ? UART_HW_FLOWCTRL_CTS_RTS : UART_HW_FLOWCTRL_DISABLE
};
/* Install UART driver and get event queue used inside driver */
@@ -408,6 +415,9 @@ modem_dte_t *esp_modem_dte_init(const esp_modem_dte_config_t *config)
res = uart_enable_pattern_det_baud_intr(esp_dte->uart_port, '\n', 1, MIN_PATTERN_INTERVAL, MIN_POST_IDLE, MIN_PRE_IDLE);
/* Set pattern queue size */
res |= uart_pattern_queue_reset(esp_dte->uart_port, CONFIG_EXAMPLE_UART_PATTERN_QUEUE_SIZE);
+ /* Starting in command mode -> explicitly disable RX interrupt */
+ uart_disable_rx_intr(esp_dte->uart_port);
+
MODEM_CHECK(res == ESP_OK, "config uart pattern failed", err_uart_pattern);
/* Create Event loop */
esp_event_loop_args_t loop_args = {
