zephyr/drivers/modem/modem_iface_uart.h
Jordan Yates 95d8deb572 modem: modem_iface_uart_async: added
Adds a communications backend based on the asynchronous UART API,
instead of the interrupt-driven UART API. The primary advantage of this
backend is an improved robustness to dropping bytes under high interrupt
or critical section loads.

Under all loads system efficiency is improved by:
 * Reducing the time spent writing out individual bytes.
 * Reducing the number of UART interrupts fired.
 * Waking up the RX thread much less often.

When utilising this backend over `nordic,nrf-uarte` on a nRF52840, the
baudrate of an esp-at modem could be pushed to at least 921600 without
dropping bytes, compared to a maximum of 230400 with the interrupt API.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-10 10:44:04 +02:00

75 lines
1.5 KiB
C

/** @file
* @brief Modem interface for UART header file.
*
* Modem interface UART handling for modem context driver.
*/
/*
* Copyright (c) 2019 Foundries.io
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_IFACE_UART_H_
#define ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_IFACE_UART_H_
#include <zephyr/kernel.h>
#ifdef __cplusplus
extern "C" {
#endif
struct modem_iface_uart_data {
/* HW flow control */
bool hw_flow_control;
/* ring buffer char buffer */
char *rx_rb_buf;
size_t rx_rb_buf_len;
/* ring buffer */
struct ring_buf rx_rb;
/* rx semaphore */
struct k_sem rx_sem;
#ifdef CONFIG_MODEM_IFACE_UART_ASYNC
/* tx semaphore */
struct k_sem tx_sem;
#endif /* CONFIG_MODEM_IFACE_UART_ASYNC */
};
/**
* @brief Init modem interface device for UART
*
* @details This can be called after the init if the UART is changed.
*
* @param *iface: modem interface to initialize.
* @param *dev_name: name of the UART device to use
*
* @retval 0 if ok, < 0 if error.
*/
int modem_iface_uart_init_dev(struct modem_iface *iface,
const struct device *dev);
/**
* @brief Init modem interface for UART
*
* @param *iface: modem interface to initialize.
* @param *data: modem interface data to use
* @param *dev_name: name of the UART device to use
*
* @retval 0 if ok, < 0 if error.
*/
int modem_iface_uart_init(struct modem_iface *iface,
struct modem_iface_uart_data *data,
const struct device *dev);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_IFACE_UART_H_ */