Loading...
Searching...
No Matches
stdio_usb.h
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_STDIO_USB_H
8#define _PICO_STDIO_USB_H
9
10#include "pico/stdio.h"
11
25
26// PICO_CONFIG: PICO_STDIO_USB_DEFAULT_CRLF, Default state of CR/LF translation for USB output, type=bool, default=PICO_STDIO_DEFAULT_CRLF, group=pico_stdio_usb
27#ifndef PICO_STDIO_USB_DEFAULT_CRLF
28#define PICO_STDIO_USB_DEFAULT_CRLF PICO_STDIO_DEFAULT_CRLF
29#endif
30
31// PICO_CONFIG: PICO_STDIO_USB_STDOUT_TIMEOUT_US, Number of microseconds to be blocked trying to write USB output before assuming the host has disappeared and discarding data, default=500000, group=pico_stdio_usb
32#ifndef PICO_STDIO_USB_STDOUT_TIMEOUT_US
33#define PICO_STDIO_USB_STDOUT_TIMEOUT_US 500000
34#endif
35
36// todo perhaps unnecessarily frequent?
37// PICO_CONFIG: PICO_STDIO_USB_TASK_INTERVAL_US, Period of microseconds between calling tud_task in the background, default=1000, advanced=true, group=pico_stdio_usb
38#ifndef PICO_STDIO_USB_TASK_INTERVAL_US
39#define PICO_STDIO_USB_TASK_INTERVAL_US 1000
40#endif
41
42// PICO_CONFIG: PICO_STDIO_USB_LOW_PRIORITY_IRQ, Explicit User IRQ number to claim for tud_task() background execution instead of letting the implementation pick a free one dynamically (deprecated), advanced=true, group=pico_stdio_usb
43#ifndef PICO_STDIO_USB_LOW_PRIORITY_IRQ
44// this variable is no longer set by default (one is claimed dynamically), but will be respected if specified
45#endif
46
47// PICO_CONFIG: PICO_STDIO_USB_ENABLE_IRQ_BACKGROUND_TASK, Enable/disable the use of a background task to call tud_task(), type=bool, default=1 if the application is not using tinyUSB directly, group=pico_stdio_usb
48#ifndef PICO_STDIO_USB_ENABLE_IRQ_BACKGROUND_TASK
49#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
50#define PICO_STDIO_USB_ENABLE_IRQ_BACKGROUND_TASK 1
51#else
52#define PICO_STDIO_USB_ENABLE_IRQ_BACKGROUND_TASK 0
53#endif
54#endif
55
56// PICO_CONFIG: PICO_STDIO_USB_ENABLE_TINYUSB_INIT, Enable/disable calling tinyUSB tusb_init() during initialization, type=bool, default=1 if the application is not using tinyUSB directly, group=pico_stdio_usb
57#ifndef PICO_STDIO_USB_ENABLE_TINYUSB_INIT
58#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
59#define PICO_STDIO_USB_ENABLE_TINYUSB_INIT 1
60#else
61#define PICO_STDIO_USB_ENABLE_TINYUSB_INIT 0
62#endif
63#endif
64
65// PICO_CONFIG: PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, default=0, group=pico_stdio_usb
66#ifndef PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS
67#define PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS 0
68#endif
69
70// PICO_CONFIG: PICO_STDIO_USB_POST_CONNECT_WAIT_DELAY_MS, Number of extra milliseconds to wait when using PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS after a host CDC connection is detected (some host terminals seem to sometimes lose transmissions sent right after connection), default=50, group=pico_stdio_usb
71#ifndef PICO_STDIO_USB_POST_CONNECT_WAIT_DELAY_MS
72#define PICO_STDIO_USB_POST_CONNECT_WAIT_DELAY_MS 50
73#endif
74
75// PICO_CONFIG: PICO_STDIO_USB_DEINIT_DELAY_MS, Number of milliseconds to wait before deinitializing stdio_usb, default=110, group=pico_stdio_usb
76#ifndef PICO_STDIO_USB_DEINIT_DELAY_MS
77#define PICO_STDIO_USB_DEINIT_DELAY_MS 110
78#endif
79
80// PICO_CONFIG: PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS, Whether `pico_stdio_usb` provides the USB descriptors needed for USB communication, type=bool, default=1 if the application is not using tinyUSB directly, group=pico_stdio_usb
81#ifndef PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS
82#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
83#define PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS 1
84#else
85#define PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS 0
86#endif
87#endif
88
89// PICO_CONFIG: PICO_STDIO_USB_CONNECTION_WITHOUT_DTR, Disable use of DTR for connection checking meaning connection is assumed to be valid, type=bool, default=0, group=pico_stdio_usb
90#ifndef PICO_STDIO_USB_CONNECTION_WITHOUT_DTR
91#define PICO_STDIO_USB_CONNECTION_WITHOUT_DTR 0
92#endif
93
94// PICO_CONFIG: PICO_STDIO_USB_DEVICE_SELF_POWERED, Set USB device as self powered device, type=bool, default=0, group=pico_stdio_usb
95#ifndef PICO_STDIO_USB_DEVICE_SELF_POWERED
96#define PICO_STDIO_USB_DEVICE_SELF_POWERED 0
97#endif
98
99// PICO_CONFIG: PICO_STDIO_USB_SUPPORT_CHARS_AVAILABLE_CALLBACK, Enable USB STDIO support for stdio_set_chars_available_callback. Can be disabled to make use of USB CDC RX callback elsewhere, type=bool, default=1, group=pico_stdio_usb
100#ifndef PICO_STDIO_USB_SUPPORT_CHARS_AVAILABLE_CALLBACK
101#define PICO_STDIO_USB_SUPPORT_CHARS_AVAILABLE_CALLBACK 1
102#endif
103
104#ifdef __cplusplus
105extern "C" {
106#endif
107
108extern stdio_driver_t stdio_usb;
109
119bool stdio_usb_init(void);
120
127
134
135#if PICO_STDIO_USB_SUPPORT_CHARS_AVAILABLE_CALLBACK
145#endif
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif
void stdio_usb_call_chars_available_callback(void)
Explicitly calls the registered USB stdio chars_available_callback.
bool stdio_usb_deinit(void)
Explicitly deinitialize USB stdio and remove it from the current set of stdin drivers.
bool stdio_usb_connected(void)
Check if there is an active stdio CDC connection to a host.
bool stdio_usb_init(void)
Explicitly initialize USB stdio and add it to the current set of stdin drivers.
Definition stdio_usb.c:306