2015-07-01 22:47:13 +02:00
|
|
|
/** @file
|
2015-11-25 08:11:30 +01:00
|
|
|
* @brief Pipe UART driver header file.
|
2015-06-01 21:35:02 +02:00
|
|
|
*
|
2015-11-25 08:11:30 +01:00
|
|
|
* A pipe UART driver that allows applications to handle all aspects of
|
2015-06-01 21:35:02 +02:00
|
|
|
* received protocol data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-06-01 21:35:02 +02:00
|
|
|
*/
|
|
|
|
|
2021-09-01 12:15:16 +02:00
|
|
|
#ifndef ZEPHYR_INCLUDE_DRIVERS_UART_PIPE_H_
|
|
|
|
#define ZEPHYR_INCLUDE_DRIVERS_UART_PIPE_H_
|
2018-09-17 02:06:26 +02:00
|
|
|
|
2015-06-01 21:35:02 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-01-22 18:38:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-07-01 22:47:13 +02:00
|
|
|
/** @brief Received data callback.
|
2015-06-01 21:35:02 +02:00
|
|
|
*
|
|
|
|
* This function is called when new data is received on UART. The off parameter
|
|
|
|
* can be used to alter offset at which received data is stored. Typically,
|
|
|
|
* when the complete data is received and a new buffer is provided off should
|
|
|
|
* be set to 0.
|
|
|
|
*
|
|
|
|
* @param buf Buffer with received data.
|
|
|
|
* @param off Data offset on next received and accumulated data length.
|
|
|
|
*
|
|
|
|
* @return Buffer to be used on next receive.
|
|
|
|
*/
|
2020-05-27 18:26:57 +02:00
|
|
|
typedef uint8_t *(*uart_pipe_recv_cb)(uint8_t *buf, size_t *off);
|
2015-06-01 21:35:02 +02:00
|
|
|
|
2015-07-01 22:47:13 +02:00
|
|
|
/** @brief Register UART application.
|
2015-06-01 21:35:02 +02:00
|
|
|
*
|
|
|
|
* This function is used to register new UART application.
|
|
|
|
*
|
|
|
|
* @param buf Initial buffer for received data.
|
|
|
|
* @param len Size of buffer.
|
|
|
|
* @param cb Callback to be called on data reception.
|
|
|
|
*/
|
2020-05-27 18:26:57 +02:00
|
|
|
void uart_pipe_register(uint8_t *buf, size_t len, uart_pipe_recv_cb cb);
|
2015-06-01 21:35:02 +02:00
|
|
|
|
2015-07-01 22:47:13 +02:00
|
|
|
/** @brief Send data over UART.
|
2015-06-01 21:35:02 +02:00
|
|
|
*
|
|
|
|
* This function is used to send data over UART.
|
|
|
|
*
|
|
|
|
* @param data Buffer with data to be send.
|
|
|
|
* @param len Size of data.
|
|
|
|
*
|
2016-03-02 14:28:45 +01:00
|
|
|
* @return 0 on success or negative error
|
2015-06-01 21:35:02 +02:00
|
|
|
*/
|
2020-05-27 18:26:57 +02:00
|
|
|
int uart_pipe_send(const uint8_t *data, int len);
|
2015-06-01 21:35:02 +02:00
|
|
|
|
2016-01-22 18:38:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2018-09-17 02:06:26 +02:00
|
|
|
|
2021-09-01 12:15:16 +02:00
|
|
|
#endif /* ZEPHYR_INCLUDE_DRIVERS_UART_PIPE_H_ */
|