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
10#pragma once
11
22
23#include <unistd.h>
24
25#include "modules.h"
26#include "isrpipe.h"
27#include "xfa.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#ifndef STDIO_RX_BUFSIZE
37#define STDIO_RX_BUFSIZE (64)
38#endif
39
40enum {
53};
54
58typedef struct {
62 void (*open)(void);
66 void (*close)(void);
76 ssize_t (*write)(const void *src, size_t len);
78
83
87void stdio_init(void);
88
89#if IS_USED(MODULE_STDIO_AVAILABLE) || DOXYGEN
99#endif
100
109
119ssize_t stdio_read(void* buffer, size_t max_len);
120
134ssize_t stdio_write(const void* buffer, size_t len);
135
139void stdio_close(void);
140
141#if defined(MODULE_STDIO_DISPATCH) || DOXYGEN
150#define STDIO_PROVIDER(_type, _open, _close, _write) \
151 XFA_CONST(stdio_provider_t, stdio_provider_xfa, 0) stdio_ ##_type = { \
152 .open = _open, \
153 .close = _close, \
154 .write = _write, \
155 };
156#else
157#define STDIO_PROVIDER(_type, _open, _close, _write) \
158 void stdio_init(void) { \
159 void (*f)(void) = _open; \
160 if (f != NULL) { \
161 f(); \
162 } \
163 } \
164 void stdio_close(void) { \
165 void (*f)(void) = _close; \
166 if (f != NULL) { \
167 f(); \
168 } \
169 } \
170 ssize_t stdio_write(const void* buffer, size_t len) { \
171 return _write(buffer, len); \
172 }
173#endif
174
175#ifdef __cplusplus
176}
177#endif
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
void stdio_clear_stdin(void)
Clear the input buffer.
@ STDIO_ESP32_SERIAL_JTAG
stdio via ESP32 debug Serial/JTAG
Definition stdio_base.h:47
@ STDIO_USBUS_CDC_ACM
stdio via USB CDC ACM (usbus)
Definition stdio_base.h:45
@ STDIO_UART
stdio via UART
Definition stdio_base.h:42
@ STDIO_RTT
stdio via Segger RTT
Definition stdio_base.h:43
@ STDIO_TINYUSB_CDC_ACM
tdio via USB CDC ACM (TinyUSB)
Definition stdio_base.h:46
@ STDIO_TELNET
stdio via telnet
Definition stdio_base.h:50
@ STDIO_ETHOS
stdio via ethos (mutiplex)
Definition stdio_base.h:51
@ STDIO_NIMBLE
stdio via BLE (NimBLE)
Definition stdio_base.h:48
@ STDIO_SEMIHOSTING
stdio via Semihosting
Definition stdio_base.h:44
@ STDIO_SLIP
stdio via SLIP (mutiplex)
Definition stdio_base.h:52
@ STDIO_NULL
dummy stdio
Definition stdio_base.h:41
@ STDIO_UDP
stdio via UDP
Definition stdio_base.h:49
isrpipe Interface
Common macros and compiler attributes/pragmas configuration.
Context structure for isrpipe.
Definition isrpipe.h:36
stdio provider struct
Definition stdio_base.h:58
void(* open)(void)
Initialize and attach the stdio provider.
Definition stdio_base.h:62
void(* close)(void)
Detach the stdio provider.
Definition stdio_base.h:66
ssize_t(* write)(const void *src, size_t len)
Write len bytes from src into stdout.
Definition stdio_base.h:76
Cross File Arrays.