drivers: modem: interface: introduce UART interface driver layer
The UART-based modem interface layer implements the modem context interface for Zephyr's UART APIs. This driver closely resembles the existing modem receiver, but conforming to the modem interface agreements. Example modem driver setup code looks like this: /* create modem context object */ static struct modem_context mctx; /* create uart interface data object and buffers */ static struct modem_iface_uart_data iface_data; static u8_t iface_isr_buf[MDM_RECV_BUF_SIZE]; static u8_t iface_rb_buf[MDM_MAX_DATA_LENGTH]; iface_data.isr_buf = &iface_isr_buf[0]; iface_data.isr_buf_len = sizeof(iface_isr_buf); iface_data.rx_rb_buf = &iface_rb_buf[0]; iface_data.rx_rb_buf_len = sizeof(iface_rb_buf); ret = modem_iface_uart_init(&mctx.iface, &iface_data, UART_DEV_NAME); Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
parent
90e778d983
commit
d56a05f7a7
4 changed files with 219 additions and 0 deletions
54
drivers/modem/modem_iface_uart.h
Normal file
54
drivers/modem/modem_iface_uart.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/** @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 {
|
||||
/* ISR char buffer */
|
||||
char *isr_buf;
|
||||
size_t isr_buf_len;
|
||||
|
||||
/* 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 for UART
|
||||
*
|
||||
* @param *iface: modem interface to initialize.
|
||||
* @param *data: modem interface data 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_ */
|
Loading…
Add table
Add a link
Reference in a new issue