qmk_firmware/drivers/serial.html

61 lines
130 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>'serial' Driver | QMK Firmware</title>
<meta name="description" content="Documentation for QMK Firmware">
<meta name="generator" content="VitePress v1.1.3">
<link rel="preload stylesheet" href="/assets/style.No8zk9aC.css" as="style">
<script type="module" src="/assets/app.BW0ncIJ9.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.DyMmIvSC.js">
<link rel="modulepreload" href="/assets/chunks/theme.xjgyWD-K.js">
<link rel="modulepreload" href="/assets/drivers_serial.md.qxjytVdM.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle has-sidebar" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/" data-v-ab179fa1><!--[--><!--]--><!--[--><!--[--><!--[--><img class="VPImage dark logo" src="/qmk-logo-dark.svg" alt data-v-8426fc1a><!--]--><!--[--><img class="VPImage light logo" src="/qmk-logo-light.svg" alt data-v-8426fc1a><!--]--><!--]--><!--]--><span data-v-ab179fa1>QMK Firmware</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="./" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Home</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://reddit.com/r/olkb" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 29 3 C 28.0625 3 27.164063 3.382813 26.5 4 C 25.835938 4.617188 25.363281 5.433594 25 6.40625 C 24.355469 8.140625 24.085938 10.394531 24.03125 13.03125 C 19.234375 13.179688 14.820313 14.421875 11.28125 16.46875 C 10.214844 15.46875 8.855469 14.96875 7.5 14.96875 C 6.089844 14.96875 4.675781 15.511719 3.59375 16.59375 C 1.425781 18.761719 1.425781 22.238281 3.59375 24.40625 L 3.84375 24.65625 C 3.3125 26.035156 3 27.488281 3 29 C 3 33.527344 5.566406 37.585938 9.5625 40.4375 C 13.558594 43.289063 19.007813 45 25 45 C 30.992188 45 36.441406 43.289063 40.4375 40.4375 C 44.433594 37.585938 47 33.527344 47 29 C 47 27.488281 46.6875 26.035156 46.15625 24.65625 L 46.40625 24.40625 C 48.574219 22.238281 48.574219 18.761719 46.40625 16.59375 C 45.324219 15.511719 43.910156 14.96875 42.5 14.96875 C 41.144531 14.96875 39.785156 15.46875 38.71875 16.46875 C 35.195313 14.433594 30.800781 13.191406 26.03125 13.03125 C 26.09375 10.546875 26.363281 8.46875 26.875 7.09375 C 27.164063 6.316406 27.527344 5.757813 27.875 5.4375 C 28.222656 5.117188 28.539063 5 29 5 C 29.460938 5 29.683594 5.125 30.03125 5.40625 C 30.378906 5.6875 30.785156 6.148438 31.3125 6.6875 C 32.253906 7.652344 33.695313 8.714844 36.09375 8.9375 C 36.539063 11.238281 38.574219 13 41 13 C 43.75 13 46 10.75 46 8 C 46 5.25 43.75 3 41 3 C 38.605469 3 36.574219 4.710938 36.09375 6.96875 C 34.3125 6.796875 33.527344 6.109375 32.75 5.3125 C 32.300781 4.851563 31.886719
<span class="line"><span>+-------+ SERIAL +-------+</span></span>
<span class="line"><span>| SSP |-----------------| SSP |</span></span>
<span class="line"><span>| | VDD | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>| | GND | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>+-------+ +-------+</span></span></code></pre></div><p>One GPIO pin is needed for the bitbang driver, as only one wire is used for receiving and transmitting data. This pin is referred to as the <code>SOFT_SERIAL_PIN</code> (SSP) in the configuration. A TRS or USB cable provides enough conductors for this driver to function.</p><h3 id="setup" tabindex="-1">Setup <a class="header-anchor" href="#setup" aria-label="Permalink to &quot;Setup&quot;"></a></h3><p>To use the bitbang driver follow these steps to activate it.</p><ol><li>Change the <code>SERIAL_DRIVER</code> to <code>bitbang</code> in your keyboards <code>rules.mk</code> file:</li></ol><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SERIAL_DRIVER = bitbang</span></span></code></pre></div><ol start="2"><li>Configure the GPIO pin of your keyboard via the <code>config.h</code> file:</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SOFT_SERIAL_PIN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> D0</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // or D1, D2, D3, E6</span></span></code></pre></div><ol start="3"><li>On ARM platforms you must turn on ChibiOS <code>PAL_USE_CALLBACKS</code> feature:</li></ol><ul><li>In <code>halconf.h</code> add the line <code>#define PAL_USE_CALLBACKS TRUE</code>.</li></ul><hr><h2 id="usart-half-duplex" tabindex="-1">USART Half-duplex <a class="header-anchor" href="#usart-half-duplex" aria-label="Permalink to &quot;USART Half-duplex&quot;"></a></h2><p>Targeting ARM boards based on ChibiOS, where communication is offloaded to a USART hardware device that supports Half-duplex operation. The advantages over bitbanging are fast, accurate timings and reduced CPU usage. Therefore it is advised to choose Half-duplex over Bitbang if MCU is capable of utilising Half-duplex, and Full-duplex can&#39;t be used instead (e.g. lack of available GPIO pins, or imcompatible PCB design).</p><h3 id="pin-configuration-1" tabindex="-1">Pin configuration <a class="header-anchor" href="#pin-configuration-1" aria-label="Permalink to &quot;Pin configuration&quot;"></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> LEFT RIGHT </span></span>
<span class="line"><span>+-------+ | | +-------+</span></span>
<span class="line"><span>| | R R | |</span></span>
<span class="line"><span>| | | SERIAL | | |</span></span>
<span class="line"><span>| TX |-----------------| TX |</span></span>
<span class="line"><span>| | VDD | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>| | GND | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>+-------+ +-------+</span></span></code></pre></div><p>Only one GPIO pin is needed for the Half-duplex driver, as only one wire is used for receiving and transmitting data. This pin is referred to as the <code>SERIAL_USART_TX_PIN</code> in the configuration. Ensure that the pin chosen for split communication can operate as the TX pin of the contoller&#39;s USART peripheral. A TRS or USB cable provides enough conductors for this driver to function. As the split connection is configured to operate in open-drain mode, an <strong>external pull-up resistor is needed to keep the line high</strong>. Resistor values of 1.5kΩ to 8.2kΩ are known to work.</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p><em><strong>Note:</strong></em> A pull-up resistor isn&#39;t required for RP2040 controllers configured with PIO subsystem.</p></div><h3 id="setup-1" tabindex="-1">Setup <a class="header-anchor" href="#setup-1" aria-label="Permalink to &quot;Setup&quot;"></a></h3><p>To use the Half-duplex driver follow these steps to activate it. If you target the Raspberry Pi RP2040 PIO implementation, start at step 2.</p><ol><li>Change the <code>SERIAL_DRIVER</code> to <code>usart</code> in your keyboards <code>rules.mk</code> file:</li></ol><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SERIAL_DRIVER = usart</span></span></code></pre></div><p>Skip to step 3.</p><ol start="2"><li>(RP2040 + PIO only!) Change the <code>SERIAL_DRIVER</code> to <code>vendor</code> in your keyboards <code>rules.mk</code> file:</li></ol><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SERIAL_DRIVER = vendor</span></span></code></pre></div><ol start="3"><li>Configure the hardware of your keyboard via the <code>config.h</code> file:</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_TX_PIN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> B6</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // The GPIO pin that is used split communication.</span></span></code></pre></div><p>For STM32 MCUs several GPIO configuration options can be changed as well. See the section <a href="#alternate-functions-for-selected-stm32-mcus">&quot;Alternate Functions for selected STM32 MCUs&quot;</a>.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> USART1_REMAP</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Remap USART TX and RX pins on STM32F103 MCUs, see table below.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_TX_PAL_MODE</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 7</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Pin &quot;alternate function&quot;, see the respective datasheet for the appropriate values for your MCU. default: 7</span></span></code></pre></div><ol start="4"><li>Decide either for <code>SERIAL</code>, <code>SIO</code>, or <code>PIO</code> subsystem. See section <a href="#choosing-a-driver-subsystem">&quot;Choosing a driver subsystem&quot;</a>.</li></ol><hr><h2 id="usart-full-duplex" tabindex="-1">USART Full-duplex <a class="header-anchor" href="#usart-full-duplex" aria-label="Permalink to &quot;USART Full-duplex&quot;"></a></h2><p>Targeting ARM boards based on ChibiOS where communication is offloaded to an USART hardware device. The advantages over bitbanging are fast, accurate timings and reduced CPU usage; therefore it is advised to choose this driver over all others where possible. Due to its internal design Full-duplex is slightly more efficient than the Half-duplex driver, but Full-duplex should be primarily chosen if Half-duplex operation is not supported by the controller&#39;s USART peripheral.</p><h3 id="pin-configuration-2" tabindex="-1">Pin configuration <a class="header-anchor" href="#pin-configuration-2" aria-label="Permalink to &quot;Pin configuration&quot;"></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span> LEFT RIGHT</span></span>
<span class="line"><span>+-------+ +-------+</span></span>
<span class="line"><span>| | SERIAL | |</span></span>
<span class="line"><span>| TX |-----------------| RX |</span></span>
<span class="line"><span>| | SERIAL | |</span></span>
<span class="line"><span>| RX |-----------------| TX |</span></span>
<span class="line"><span>| | VDD | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>| | GND | |</span></span>
<span class="line"><span>| |-----------------| |</span></span>
<span class="line"><span>+-------+ +-------+</span></span></code></pre></div><p>Two GPIO pins are needed for the Full-duplex driver, as two distinct wires are used for receiving and transmitting data. The pin transmitting data is the <code>TX</code> pin and refereed to as the <code>SERIAL_USART_TX_PIN</code>, the pin receiving data is the <code>RX</code> pin and refereed to as the <code>SERIAL_USART_RX_PIN</code> in this configuration. Please note that <code>TX</code> pin of the master half has to be connected with the <code>RX</code> pin of the slave half and the <code>RX</code> pin of the master half has to be connected with the <code>TX</code> pin of the slave half! Usually this pin swap has to be done outside of the MCU e.g. with cables or on the PCB. Some MCUs like the STM32F303 used on the Proton-C allow this pin swap directly inside the MCU. A TRRS or USB cable provides enough conductors for this driver to function.</p><p>To use this driver the USART peripherals <code>TX</code> and <code>RX</code> pins must be configured with the correct Alternate-functions. If you are using a Proton-C development board everything is already setup, same is true for STM32F103 MCUs. For MCUs which are using a modern flexible GPIO configuration you have to specify these by setting <code>SERIAL_USART_TX_PAL_MODE</code> and <code>SERIAL_USART_RX_PAL_MODE</code>. Refer to the corresponding datasheets of your MCU or find those settings in the section <a href="#alternate-functions-for-selected-stm32-mcus">&quot;Alternate Functions for selected STM32 MCUs&quot;</a>.</p><h3 id="setup-2" tabindex="-1">Setup <a class="header-anchor" href="#setup-2" aria-label="Permalink to &quot;Setup&quot;"></a></h3><p>To use the Full-duplex driver follow these steps to activate it. If you target the Raspberry Pi RP2040 PIO implementation, start at step 2</p><ol><li>Change the <code>SERIAL_DRIVER</code> to <code>usart</code> in your keyboards <code>rules.mk</code> file:</li></ol><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SERIAL_DRIVER = usart</span></span></code></pre></div><p>Skip to step 3</p><ol start="2"><li>(RP2040 + PIO only!) Change the <code>SERIAL_DRIVER</code> to <code>vendor</code> in your keyboards <code>rules.mk</code> file:</li></ol><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SERIAL_DRIVER = vendor</span></span></code></pre></div><ol start="3"><li>Configure the hardware of your keyboard via the <code>config.h</code> file:</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_FULL_DUPLEX</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Enable full duplex operation mode.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_TX_PIN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> B6</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // USART TX pin</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_RX_PIN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> B7</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // USART RX pin</span></span></code></pre></div><p>For STM32 MCUs several GPIO configuration options, including the ability for <code>TX</code> to <code>RX</code> pin swapping, can be changed as well. See the section <a href="#alternate-functions-for-selected-stm32-mcus">&quot;Alternate Functions for selected STM32 MCUs&quot;</a>.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_PIN_SWAP</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Swap TX and RX pins if keyboard is master halve. (Only available on some MCUs)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> USART1_REMAP</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Remap USART TX and RX pins on STM32F103 MCUs, see table below.</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_TX_PAL_MODE</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 7</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Pin &quot;alternate function&quot;, see the respective datasheet for the appropriate values for your MCU. default: 7</span></span></code></pre></div><ol start="4"><li>Decide either for <code>SERIAL</code>, <code>SIO</code>, or <code>PIO</code> subsystem. See section <a href="#choosing-a-driver-subsystem">&quot;Choosing a driver subsystem&quot;</a>.</li></ol><hr><h2 id="choosing-a-driver-subsystem" tabindex="-1">Choosing a driver subsystem <a class="header-anchor" href="#choosing-a-driver-subsystem" aria-label="Permalink to &quot;Choosing a driver subsystem&quot;"></a></h2><h3 id="the-serial-driver" tabindex="-1">The <code>SERIAL</code> driver <a class="header-anchor" href="#the-serial-driver" aria-label="Permalink to &quot;The `SERIAL` driver&quot;"></a></h3><p>The <code>SERIAL</code> Subsystem is supported for the majority of ChibiOS MCUs and should be used whenever supported. Follow these steps in order to activate it:</p><ol><li>In your keyboards <code>halconf.h</code> add:</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> HAL_USE_SERIAL</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span></code></pre></div><ol start="2"><li>In your keyboards <code>mcuconf.h</code>: activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the <code>mcuconf.h</code> files of your MCU that ship with ChibiOS.</li></ol><p>Just below <code>#include_next &lt;mcuconf.h&gt;</code> add:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#include_next</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &lt;mcuconf.h&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#undef</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STM32_SERIAL_USE_USARTn</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STM32_SERIAL_USE_USARTn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span></code></pre></div><p>Where &#39;n&#39; matches the peripheral number of your selected USART on the MCU.</p><ol start="3"><li>In you keyboards <code>config.h</code>: override the default USART <code>SERIAL</code> driver if you use a USART peripheral that does not belong to the default selected <code>SD1</code> driver. For instance, if you selected <code>STM32_SERIAL_USE_USART3</code> the matching driver would be <code>SD3</code>.</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> #define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_DRIVER</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> SD3</span></span></code></pre></div><h3 id="the-sio-driver" tabindex="-1">The <code>SIO</code> driver <a class="header-anchor" href="#the-sio-driver" aria-label="Permalink to &quot;The `SIO` driver&quot;"></a></h3><p>The <code>SIO</code> Subsystem was added to ChibiOS with the 21.11 release and is only supported on selected MCUs. It should only be chosen when the <code>SERIAL</code> subsystem is not supported by your MCU.</p><p>Follow these steps in order to activate it:</p><ol><li>In your keyboards <code>halconf.h</code> add:</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> HAL_USE_SIO</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span></code></pre></div><ol start="2"><li>In your keyboards <code>mcuconf.h:</code> activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the <code>mcuconf.h</code> files of your MCU that ship with ChibiOS.</li></ol><p>Just below <code>#include_next &lt;mcuconf.h&gt;</code> add:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#include_next</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &lt;mcuconf.h&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#undef</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STM32_SIO_USE_USARTn</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> STM32_SIO_USE_USARTn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span></code></pre></div><p>Where &#39;n&#39; matches the peripheral number of your selected USART on the MCU.</p><ol start="3"><li>In the keyboard&#39;s <code>config.h</code> file: override the default USART <code>SIO</code> driver if you use a USART peripheral that does not belong to the default selected <code>SIOD1</code> driver. For instance, if you selected <code>STM32_SERIAL_USE_USART3</code> the matching driver would be <code>SIOD3</code>.</li></ol><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> #define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_USART_DRIVER</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> SIOD3</span></span></code></pre></div><h3 id="the-pio-driver" tabindex="-1">The <code>PIO</code> driver <a class="header-anchor" href="#the-pio-driver" aria-label="Permalink to &quot;The `PIO` driver&quot;"></a></h3><p>The <code>PIO</code> subsystem is a Raspberry Pi RP2040 specific implementation, using an integrated PIO peripheral and is therefore only available on this MCU. Because of the flexible nature of PIO peripherals, <strong>any</strong> GPIO pin can be used as a <code>TX</code> or <code>RX</code> pin. Half-duplex and Full-duplex operation modes are fully supported with this driver. Half-duplex uses the built-in pull-ups and GPIO manipulation of the RP2040 to drive the line high by default, thus an external pull-up resistor <strong>is not required</strong>.</p><p>Optionally, the PIO peripheral utilized for split communication can be changed with the following define in config.h:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SERIAL_PIO_USE_PIO1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Force the usage of PIO1 peripheral, by default the Serial implementation uses the PIO0 peripheral</span></span></code></pre></div><p>The Serial PIO program uses 2 state machines, 13 instructions and the complete interrupt handler of the PIO peripheral it is running on.</p><hr><h2 id="advanced-configuration" tabindex="-1">Advanced Configuration <a class="header-anchor" href="#advanced-configuration" aria-label="Permalink to &quot;Advanced Configuration&quot;"></a></h2><p>There are several advanced configuration options that can be defined in your keyboards <code>config.h</code> file:</p><h3 id="baudrate" tabindex="-1">Baudrate <a class="header-anchor" href="#baudrate" aria-label="Permalink to &quot;Baudrate&quot;"></a></h3><p>If you&#39;re having issues or need a higher baudrate with serial communication, you can change the baudrate which in turn controls the communication speed for serial. You want to lower the baudrate if you experience failed transactions.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SELECT_SOFT_SERIAL_SPEED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {#}</span></span></code></pre></div><table><thead><tr><th>Speed</th><th>Bitbang</th><th>Half-duplex and Full-duplex</th></tr></thead><tbody><tr><td><code>0</code></td><td>189000 baud (experimental)</td><td>460800 baud</
<script>window.__VP_HASH_MAP__=JSON.parse("{\"changelog_20200530.md\":\"Dk-vRpTQ\",\"changelog_20200229.md\":\"DNsowwM1\",\"changelog_20190830.md\":\"Drtq3lMy\",\"changelog_20200829.md\":\"CoqrOffn\",\"changelog_20201128.md\":\"7XXL02Bn\",\"changelog_20210227.md\":\"BWOtCaeS\",\"cli_tab_complete.md\":\"ChaxfzYo\",\"configurator_architecture.md\":\"DEFTvTlS\",\"coding_conventions_c.md\":\"DdrpXBEh\",\"config_options.md\":\"DvMeqlpB\",\"cli_configuration.md\":\"CGSB128P\",\"cli_development.md\":\"3xFA2OvS\",\"configurator_step_by_step.md\":\"CB5U_ksW\",\"api_development_environment.md\":\"EhJClb9f\",\"changelog_20210529.md\":\"CR1YNfZX\",\"changelog_20220827.md\":\"DjPthqDk\",\"changelog_20220528.md\":\"BX3CCY1Z\",\"configurator_default_keymaps.md\":\"B3v8dlHd\",\"changelog_20211127.md\":\"ClUawWkq\",\"api_docs.md\":\"CRoD6CbL\",\"changelog_20230827.md\":\"NSPhmB6l\",\"changelog_20230528.md\":\"nX9R48zP\",\"breaking_changes.md\":\"BtdqWQlY\",\"arm_debugging.md\":\"BH-H2Ukz\",\"changelog_20240526.md\":\"DAmAEDG5\",\"breaking_changes_instructions.md\":\"BAjIGeJb\",\"chibios_upgrade_instructions.md\":\"B5dMtL5R\",\"cli.md\":\"BLzAdA6l\",\"capabilities_inc.md\":\"Ca9zpMce\",\"cli_commands.md\":\"DGx-qNiE\",\"changelog_20230226.md\":\"Cg0AYxIn\",\"api_development_overview.md\":\"Dcey4ntL\",\"compatible_microcontrollers.md\":\"6HA6FJZJ\",\"drivers_flash.md\":\"DhWcHp8S\",\"documentation_templates.md\":\"Bhkum0wD\",\"changelog_20221126.md\":\"DpbrnXeC\",\"documentation_best_practices.md\":\"BtEjePaZ\",\"api_overview.md\":\"0FPaUsMb\",\"drivers_gpio.md\":\"C5PvyJVh\",\"data_driven_config.md\":\"BvLQ7P20\",\"custom_matrix.md\":\"DMnRw_5l\",\"configurator_troubleshooting.md\":\"BxGLPT8G\",\"changelog_20220226.md\":\"BWO5r_ec\",\"custom_quantum_functions.md\":\"DrUNiV1i\",\"feature_debounce_type.md\":\"CUrSp0Iy\",\"feature_layers.md\":\"8GwBUTZN\",\"feature_eeprom.md\":\"a0eoTZm7\",\"feature_advanced_keycodes.md\":\"CX8dJkY-\",\"feature_converters.md\":\"DFKin1io\",\"features_bootmagic.md\":\"CeNSUsBQ\",\"features_backlight.md\":\"D7R4FkYo\",\"features_auto_shift.md\":\"B9HLt3QM\",\"drivers_spi.md\":\"tJVeIT7e\",\"features_digitizer.md\":\"DGIGZFVx\",\"features_dynamic_macros.md\":\"CrJ1vhBA\",\"features_combo.md\":\"C-GfDyXJ\",\"features_dip_switch.md\":\"DtBOdc98\",\"features_command.md\":\"Byl9YoT7\",\"features_caps_word.md\":\"BDQGM0-x\",\"faq_general.md\":\"BC3pFw4U\",\"easy_maker.md\":\"DAfbIK4w\",\"drivers_uart.md\":\"BNBs-m3h\",\"faq_build.md\":\"DL_WezA1\",\"drivers_serial.md\":\"qxjytVdM\",\"faq_debug.md\":\"DuThValw\",\"changelog_20231126.md\":\"D2Ok5QAf\",\"faq_keymap.md\":\"BsEmEZTo\",\"capabilities.md\":\"DgKwcj5n\",\"breaking_changes_history.md\":\"CkzdD6x8\",\"drivers_apa102.md\":\"Qb-KXRpF\",\"driver_installation_zadig.md\":\"CX9-BACt\",\"coding_conventions_python.md\":\"BV-OK1s5\",\"contributing.md\":\"DLsp4vSA\",\"drivers_adc.md\":\"DzU8txf8\",\"drivers_eeprom.md\":\"B_6soqar\",\"drivers_audio.md\":\"mqaz6p5N\",\"drivers_i2c.md\":\"Cuj87reB\",\"feature_layouts.md\":\"qcy8hNMO\",\"feature_macros.md\":\"By1M5R8G\",\"features_audio.md\":\"DWNYte3W\",\"faq_misc.md\":\"qGrhOTu4\",\"features_hd44780.md\":\"15K40o_e\",\"features_encoders.md\":\"B2SX3hG2\",\"features_grave_esc.md\":\"mUNEjUYS\",\"feature_userspace.md\":\"BsmY9yWw\",\"drivers_ws2812.md\":\"D9E3Wb-Y\",\"features_bluetooth.md\":\"CiAjl875\",\"changelog_20240225.md\":\"B4-WrXj6\",\"changelog_20210828.md\":\"DNbHIuuM\",\"features_haptic_feedback.md\":\"DS8CmC7e\",\"features_led_indicators.md\":\"CCZhjHe9\",\"features_joystick.md\":\"CW0gZHec\",\"features_key_lock.md\":\"IjFq9dYs\",\"features_autocorrect.md\":\"DHRDcuho\",\"features_midi.md\":\"u3tHPteB\",\"features_led_matrix.md\":\"D444t5Um\",\"features_mouse_keys.md\":\"C3P3pYuE\",\"features_leader_key.md\":\"DBQTnBRh\",\"features_os_detection.md\":\"DZKTWvSd\",\"features_oled_driver.md\":\"D9wJVdL1\",\"quantum_painter_lvgl.md\":\"DobNbSgA\",\"newbs_testing_debugging.md\":\"D-c7Gle_\",\"features_rawhid.md\":\"bKKG3KCa\",\"newbs_building_firmware_configurator.md\":\"yyo-1QDE\",\"features_sequencer.md\":\"
</body>
</html>