A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.wokwi.com/chips-api/uart below:

UART API | Wokwi Docs

To create an UART device, first call uart_init, passing in an uart_config_t struct. This struct defines the RX/TX pins, the baud rate, and the rx/write_done callbacks.

Initializes UART device. The config argument defines the pins, configuration, and callbacks for the UART device. It contains the following fields:

Both of the callbacks (rx_data, write_done) are optional. They all use the user_data pointer as their first argument.

static void on_uart_rx_data(void *user_data, uint8_t byte) {

}

static uint8_t on_uart_write_done(void *user_data) {

}



const uart_config_t uart1 = {
.tx = pin_init("TX", INPUT_PULLUP),
.rx = pin_init("RX", INPUT),
.baud_rate = 115200,
.rx_data = on_uart_rx_data,
.write_done = on_uart_write_done,
.user_data = chip,
};

Write count bytes from the memory pointed to by buffer to the given uart device.
Returns true on success, or false if the UART device is already busy transmitting data from a previous uart_write call (and the new data won't be transmitted).

The data starts transmitting after uart_write returns. Once Wokwi finishes transmitting the data, the write_done callback is called (from the uart_config_t structure that you passed to uart_init).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4