Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tty.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Linaro Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_CONSOLE_TTY_H_
8#define ZEPHYR_INCLUDE_CONSOLE_TTY_H_
9
10#include <sys/types.h>
11#include <zephyr/types.h>
12#include <zephyr/kernel.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18struct tty_serial {
19 const struct device *uart_dev;
20
21 struct k_sem rx_sem;
26
27 struct k_sem tx_sem;
32};
33
52int tty_init(struct tty_serial *tty, const struct device *uart_dev);
53
63static inline void tty_set_rx_timeout(struct tty_serial *tty, int32_t timeout)
64{
65 tty->rx_timeout = timeout;
66}
67
77static inline void tty_set_tx_timeout(struct tty_serial *tty, int32_t timeout)
78{
79 tty->tx_timeout = timeout;
80}
81
93int tty_set_rx_buf(struct tty_serial *tty, void *buf, size_t size);
94
108int tty_set_tx_buf(struct tty_serial *tty, void *buf, size_t size);
109
121ssize_t tty_read(struct tty_serial *tty, void *buf, size_t size);
122
133ssize_t tty_write(struct tty_serial *tty, const void *buf, size_t size);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif /* ZEPHYR_INCLUDE_CONSOLE_TTY_H_ */
static void tty_set_rx_timeout(struct tty_serial *tty, int32_t timeout)
Set receive timeout for tty device.
Definition: tty.h:63
static void tty_set_tx_timeout(struct tty_serial *tty, int32_t timeout)
Set transmit timeout for tty device.
Definition: tty.h:77
int tty_init(struct tty_serial *tty, const struct device *uart_dev)
Initialize serial port object (classically known as tty).
ssize_t tty_read(struct tty_serial *tty, void *buf, size_t size)
Read data from a tty device.
int tty_set_rx_buf(struct tty_serial *tty, void *buf, size_t size)
Set receive buffer for tty device.
ssize_t tty_write(struct tty_serial *tty, const void *buf, size_t size)
Write data to tty device.
int tty_set_tx_buf(struct tty_serial *tty, void *buf, size_t size)
Set transmit buffer for tty device.
Public kernel APIs.
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT32_TYPE__ int32_t
Definition: stdint.h:74
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:403
Definition: tty.h:18
uint8_t * rx_ringbuf
Definition: tty.h:22
uint32_t tx_ringbuf_sz
Definition: tty.h:29
uint16_t rx_put
Definition: tty.h:24
const struct device * uart_dev
Definition: tty.h:19
uint16_t tx_put
Definition: tty.h:30
uint32_t rx_ringbuf_sz
Definition: tty.h:23
uint16_t rx_get
Definition: tty.h:24
uint16_t tx_get
Definition: tty.h:30
int32_t rx_timeout
Definition: tty.h:25
struct k_sem rx_sem
Definition: tty.h:21
int32_t tx_timeout
Definition: tty.h:31
uint8_t * tx_ringbuf
Definition: tty.h:28
struct k_sem tx_sem
Definition: tty.h:27