@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
pico_stdio

Customized stdio support allowing for input and output from UART, USB, semi-hosting etc. More...

## Topics

| pico_stdio_semihosting
| Experimental support for stdout using RAM semihosting.
| pico_stdio_uart
| Support for stdin/stdout using UART.
| pico_stdio_rtt
| Support for stdin/stdout using SEGGER RTT.
| pico_stdio_usb
| Support for stdin/stdout over USB serial (CDC).

## Functions

bool | stdio_init_all (void)
| Initialize all of the present standard stdio types that are linked into the binary.
bool | stdio_deinit_all (void)
| Deinitialize all of the present standard stdio types that are linked into the binary.
void | stdio_flush (void)
| Flushes any buffered output.
int | stdio_getchar_timeout_us (uint32_t timeout_us)
| Return a character from stdin if there is one available within a timeout.
static int | getchar_timeout_us (uint32_t timeout_us)
| Alias for stdio_getchar_timeout_us for backwards compatibility.
void | stdio_set_driver_enabled (stdio_driver_t *driver, bool enabled)
| Adds or removes a driver from the list of active drivers used for input/output.
void | stdio_filter_driver (stdio_driver_t *driver)
| Control limiting of output to a single driver.
void | stdio_set_translate_crlf (stdio_driver_t *driver, bool translate)
| control conversion of line feeds to carriage return on transmissions
int | stdio_putchar_raw (int c)
| putchar variant that skips any CR/LF conversion if enabled
static int | putchar_raw (int c)
| Alias for stdio_putchar_raw for backwards compatibility.
int | stdio_puts_raw (const char *s)
| puts variant that skips any CR/LF conversion if enabled
static int | puts_raw (const char *s)
| Alias for stdio_puts_raw for backwards compatibility.
void | stdio_set_chars_available_callback (void(*fn)(void *), void *param)
| get notified when there are input characters available
int | stdio_get_until (char *buf, int len, absolute_time_t until)
| Waits until a timeout to read at least one character into a buffer.
int | stdio_put_string (const char *s, int len, bool newline, bool cr_translation)
| Prints a buffer to stdout with optional newline and carriage return insertion.
int | stdio_getchar (void)
| Alias for getchar that definitely does not go thru the implementation in the standard C library even when PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS == 0.
int | stdio_putchar (int)
| Alias for putchar that definitely does not go thru the implementation in the standard C library even when PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS == 0.
int | stdio_puts (const char *s)
| Alias for puts that definitely does not go thru the implementation in the standard C library even when PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS == 0.
int | stdio_vprintf (const char *format, va_list va)
| Alias for vprintf that definitely does not go thru the implementation in the standard C library even when PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS == 0.
int | __printflike (1, 0) stdio_printf(const char *format
| Alias for printf that definitely does not go thru the implementation in the standard C library even when PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS == 0.

## Detailed Description

Customized stdio support allowing for input and output from UART, USB, semi-hosting etc.

Note the API for adding additional input output devices is not yet considered stable

## Function Documentation

## stdio_deinit_all()

bool stdio_deinit_all | ( | void |  | ) |

Deinitialize all of the present standard stdio types that are linked into the binary.

This method currently only supports stdio_uart and stdio_semihosting

Returns
  true if all outputs was successfully deinitialized, false otherwise.

See also
  stdio_uart, stdio_usb, stdio_semihosting, stdio_rtt

## stdio_filter_driver()

void stdio_filter_driver | ( | stdio_driver_t * | driver | ) |

Control limiting of output to a single driver.

Note
  this method should always be called on an initialized driver

Parameters

  driver | if non-null then output only that driver will be used for input/output (assuming it is in the list of enabled drivers). if NULL then all enabled drivers will be used

## stdio_get_until()

int stdio_get_until | ( | char * | buf,
|  | int | len,
|  | absolute_time_t | until )

Waits until a timeout to read at least one character into a buffer.

This method returns as soon as input is available, but more characters may be returned up to the end of the buffer.

Parameters

  buf | the buffer to read into
  len | the length of the buffer

Returns
  the number of characters read or PICO_ERROR_TIMEOUT

Parameters

  until | the time after which to return PICO_ERROR_TIMEOUT if no characters are available

## stdio_getchar_timeout_us()

int stdio_getchar_timeout_us | ( | uint32_t | timeout_us | ) |

Return a character from stdin if there is one available within a timeout.

Parameters

  timeout_us | the timeout in microseconds, or 0 to not wait for a character if none available.

Returns
  the character from 0-255 or PICO_ERROR_TIMEOUT if timeout occurs

## stdio_init_all()

bool stdio_init_all | ( | void |  | ) |

Initialize all of the present standard stdio types that are linked into the binary.

Call this method once you have set up your clocks to enable the stdio support for UART, USB, semihosting, and RTT based on the presence of the respective libraries in the binary.

When stdio_usb is configured, this method can be optionally made to block, waiting for a connection via the variables specified in stdio_usb_init (i.e. PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS)

Returns
  true if at least one output was successfully initialized, false otherwise.

See also
  stdio_uart, stdio_usb, stdio_semihosting, stdio_rtt

## stdio_put_string()

int stdio_put_string | ( | const char * | s,
|  | int | len,
|  | bool | newline,
|  | bool | cr_translation )

Prints a buffer to stdout with optional newline and carriage return insertion.

This method returns as soon as input is available, but more characters may be returned up to the end of the buffer.

Parameters

  s | the characters to print
  len | the length of s
  newline | true if a newline should be added after the string
  cr_translation | true if line feed to carriage return translation should be performed

Returns
  the number of characters written

## stdio_set_chars_available_callback()

void stdio_set_chars_available_callback | ( | void(* | fn )(void *),
|  | void * | param )

get notified when there are input characters available

Parameters

  fn | Callback function to be called when characters are available. Pass NULL to cancel any existing callback
  param | Pointer to pass to the callback

## stdio_set_driver_enabled()

void stdio_set_driver_enabled | ( | stdio_driver_t * | driver,
|  | bool | enabled )

Adds or removes a driver from the list of active drivers used for input/output.

Note
  this method should always be called on an initialized driver and is not re-entrant

Parameters

  driver | the driver
  enabled | true to add, false to remove

## stdio_set_translate_crlf()

void stdio_set_translate_crlf | ( | stdio_driver_t * | driver,
|  | bool | translate )

control conversion of line feeds to carriage return on transmissions

Note
  this method should always be called on an initialized driver

Parameters

  driver | the driver
  translate | If true, convert line feeds to carriage return on transmissions