Loading...
Searching...
No Matches
stdio_base.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
3 * 2018 Freie Universität Berlin
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
24#ifndef STDIO_BASE_H
25#define STDIO_BASE_H
26
27#include <unistd.h>
28
29#include "modules.h"
30#include "isrpipe.h"
31#include "xfa.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifndef STDIO_RX_BUFSIZE
41#define STDIO_RX_BUFSIZE (64)
42#endif
43
44enum {
56 STDIO_SLIP, /*<< stdio via SLIP (mutiplex) */
57};
58
62typedef struct {
66 void (*open)(void);
70 void (*close)(void);
80 ssize_t (*write)(const void *src, size_t len);
82
87
91void stdio_init(void);
92
93#if IS_USED(MODULE_STDIO_AVAILABLE) || DOXYGEN
103#endif
104
114ssize_t stdio_read(void* buffer, size_t max_len);
115
129ssize_t stdio_write(const void* buffer, size_t len);
130
134void stdio_close(void);
135
136#if defined(MODULE_STDIO_DISPATCH) || DOXYGEN
145#define STDIO_PROVIDER(_type, _open, _close, _write) \
146 XFA_CONST(stdio_provider_xfa, 0) stdio_provider_t stdio_ ##_type = { \
147 .open = _open, \
148 .close = _close, \
149 .write = _write, \
150 };
151#else
152#define STDIO_PROVIDER(_type, _open, _close, _write) \
153 void stdio_init(void) { \
154 void (*f)(void) = _open; \
155 if (f != NULL) { \
156 f(); \
157 } \
158 } \
159 void stdio_close(void) { \
160 void (*f)(void) = _close; \
161 if (f != NULL) { \
162 f(); \
163 } \
164 } \
165 ssize_t stdio_write(const void* buffer, size_t len) { \
166 return _write(buffer, len); \
167 }
168#endif
169
170#ifdef __cplusplus
171}
172#endif
174#endif /* STDIO_BASE_H */
void stdio_close(void)
Disable stdio and detach stdio providers.
isrpipe_t stdin_isrpipe
isrpipe for writing stdin input to
void stdio_init(void)
initialize the module
ssize_t stdio_read(void *buffer, size_t max_len)
read len bytes from stdio uart into buffer
int stdio_available(void)
Get the number of bytes available for reading from stdio.
ssize_t stdio_write(const void *buffer, size_t len)
write len bytes from buffer into STDOUT
@ STDIO_ESP32_SERIAL_JTAG
stdio via ESP32 debug Serial/JTAG
Definition stdio_base.h:51
@ STDIO_USBUS_CDC_ACM
stdio via USB CDC ACM (usbus)
Definition stdio_base.h:49
@ STDIO_UART
stdio via UART
Definition stdio_base.h:46
@ STDIO_RTT
stdio via Segger RTT
Definition stdio_base.h:47
@ STDIO_TINYUSB_CDC_ACM
tdio via USB CDC ACM (TinyUSB)
Definition stdio_base.h:50
@ STDIO_TELNET
stdio via telnet
Definition stdio_base.h:54
@ STDIO_ETHOS
stdio via ethos (mutiplex)
Definition stdio_base.h:55
@ STDIO_NIMBLE
stdio via BLE (NimBLE)
Definition stdio_base.h:52
@ STDIO_SEMIHOSTING
stdio via Semihosting
Definition stdio_base.h:48
@ STDIO_NULL
dummy stdio
Definition stdio_base.h:45
@ STDIO_UDP
stdio via UDP
Definition stdio_base.h:53
isrpipe Interface
Common macros and compiler attributes/pragmas configuration.
Context structure for isrpipe.
Definition isrpipe.h:37
stdio provider struct
Definition stdio_base.h:62
Cross File Arrays.