<spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STM32_SERIAL_USE_USART2</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span></code></pre></div><p>Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303.</p><table><thead><tr><th><code>config.h</code> override</th><th>Description</th><th>Default Value</th></tr></thead><tbody><tr><td><code>#define UART_DRIVER</code></td><td>USART peripheral to use - USART1 -><code>SD1</code>, USART2 -><code>SD2</code> etc.</td><td><code>SD1</code></td></tr><tr><td><code>#define UART_TX_PIN</code></td><td>The pin to use for TX</td><td><code>A9</code></td></tr><tr><td><code>#define UART_TX_PAL_MODE</code></td><td>The alternate function mode for TX</td><td><code>7</code></td></tr><tr><td><code>#define UART_RX_PIN</code></td><td>The pin to use for RX</td><td><code>A10</code></td></tr><tr><td><code>#define UART_RX_PAL_MODE</code></td><td>The alternate function mode for RX</td><td><code>7</code></td></tr><tr><td><code>#define UART_CTS_PIN</code></td><td>The pin to use for CTS</td><td><code>A11</code></td></tr><tr><td><code>#define UART_CTS_PAL_MODE</code></td><td>The alternate function mode for CTS</td><td><code>7</code></td></tr><tr><td><code>#define UART_RTS_PIN</code></td><td>The pin to use for RTS</td><td><code>A12</code></td></tr><tr><td><code>#define UART_RTS_PAL_MODE</code></td><td>The alternate function mode for RTS</td><td><code>7</code></td></tr></tbody></table><h2id="api"tabindex="-1">API <aclass="header-anchor"href="#api"aria-label="Permalink to "API {#api}""></a></h2><h3id="api-uart-init"tabindex="-1"><code>void uart_init(uint32_t baud)</code><aclass="header-anchor"href="#api-uart-init"aria-label="Permalink to "`void uart_init(uint32_t baud)` {#api-uart-init}""></a></h3><p>Initialize the UART driver. This function must be called only once, before any of the below functions can be called.</p><h4id="api-uart-init-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-uart-init-arguments"aria-label="Permalink to "Arguments {#api-uart-init-arguments}""></a></h4><ul><li><code>uint32_t baud</code><br> The baud rate to transmit and receive at. This may depend on the device you are communicating with. Common values are 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200.</li></ul><hr><h3id="api-uart-write"tabindex="-1"><code>void uart_write(uint8_t data)</code><aclass="header-anchor"href="#api-uart-write"aria-label="Permalink to "`void uart_write(uint8_t data)` {#api-uart-write}""></a></h3><p>Transmit a single byte.</p><h4id="api-uart-write-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-uart-write-arguments"aria-label="Permalink to "Arguments {#api-uart-write-arguments}""></a></h4><ul><li><code>uint8_t data</code><br> The byte to write.</li></ul><hr><h3id="api-uart-read"tabindex="-1"><code>uint8_t uart_read(void)</code><aclass="header-anchor"href="#api-uart-read"aria-label="Permalink to "`uint8_t uart_read(void)` {#api-uart-read}""></a></h3><p>Receive a single byte.</p><h4id="api-uart-read-return"tabindex="-1">Return Value <aclass="header-anchor"href="#api-uart-read-return"aria-label="Permalink to "Return Value {#api-uart-read-return}""></a></h4><p>The byte read from the receive buffer. This function will block if the buffer is empty (ie. no data to read).</p><hr><h3id="api-uart-transmit"tabindex="-1"><code>void uart_transmit(const uint8_t *data, uint16_t length)</code><aclass="header-anchor"href="#api-uart-transmit"aria-label="Permalink to "`void uart_transmit(const uint8_t *data, uint16_t length)` {#api-uart-transmit}""></a></h3><p>Transmit multiple bytes.</p><h4id="api-uart-transmit-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-uart-transmit-ar