05eb9644dc
So far all received bytes over UART where blindly drained and pushed to ring_buf. This approach is okay for UART devices without configured HW flow control, as it basically decouples data processing from ISR handler and gives more time before data overrun. However when HW flow control is enabled, such behavior somehow suppresses UART flow control advantage, because data can overrun when pushing to ring_buf. Allow drivers utilizing modem_context framework to pass information about whether HW flow control is enabled or not. If it is enabled, then read data from UART FIFO to the point when RX ring_buf is totally filled and follow such situation by disabling RX interrupt. Incoming data will be paused on HW level, so there is lots of time for RX thread to process ring_buf content. Reenable RX interrupts after all data in ring_buf is processed, so that number of context switches is kept at minimum level. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
68 lines
1.4 KiB
C
68 lines
1.4 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 <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;
|
|
};
|
|
|
|
/**
|
|
* @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 char *dev_name);
|
|
|
|
/**
|
|
* @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 char *dev_name);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_IFACE_UART_H_ */
|