qmk_firmware/assets/drivers_spi.md.CEZ7mzyt.js

16 lines
15 KiB
JavaScript
Raw Normal View History

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
const __pageData = JSON.parse('{"title":"SPI Master Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/spi.md","filePath":"drivers/spi.md","lastUpdated":null}');
const _sfc_main = { name: "drivers/spi.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="spi-master-driver" tabindex="-1">SPI Master Driver <a class="header-anchor" href="#spi-master-driver" aria-label="Permalink to &quot;SPI Master Driver {#spi-master-driver}&quot;"></a></h1><p>The SPI Master drivers used in QMK have a set of common functions to allow portability between MCUs.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to &quot;Usage {#usage}&quot;"></a></h2><p>In most cases, the SPI Master driver code is automatically included if you are using a feature or driver which requires it, such as <a href="./../features/oled_driver">OLED</a>.</p><p>However, if you need to use the driver standalone, add the following to your <code>rules.mk</code>:</p><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;">SPI_DRIVER_REQUIRED = yes</span></span></code></pre></div><p>You can then call the SPI API by including <code>spi_master.h</code> in your code.</p><h2 id="avr-configuration" tabindex="-1">AVR Configuration <a class="header-anchor" href="#avr-configuration" aria-label="Permalink to &quot;AVR Configuration {#avr-configuration}&quot;"></a></h2><p>No special setup is required - just connect the <code>SS</code>, <code>SCK</code>, <code>MOSI</code> and <code>MISO</code> pins of your SPI devices to the matching pins on the MCU:</p><table><thead><tr><th>MCU</th><th><code>SS</code></th><th><code>SCK</code></th><th><code>MOSI</code></th><th><code>MISO</code></th></tr></thead><tbody><tr><td>ATmega16/32U2/4</td><td><code>B0</code></td><td><code>B1</code></td><td><code>B2</code></td><td><code>B3</code></td></tr><tr><td>AT90USB64/128/162</td><td><code>B0</code></td><td><code>B1</code></td><td><code>B2</code></td><td><code>B3</code></td></tr><tr><td>ATmega32A</td><td><code>B4</code></td><td><code>B7</code></td><td><code>B5</code></td><td><code>B6</code></td></tr><tr><td>ATmega328/P</td><td><code>B2</code></td><td><code>B5</code></td><td><code>B3</code></td><td><code>B4</code></td></tr></tbody></table><p>You may use more than one slave select pin, not just the <code>SS</code> pin. This is useful when you have multiple devices connected and need to communicate with them individually. <code>SPI_SS_PIN</code> can be passed to <code>spi_start()</code> to refer to <code>SS</code>.</p><h2 id="arm-configuration" tabindex="-1">ChibiOS/ARM Configuration <a class="header-anchor" href="#arm-configuration" aria-label="Permalink to &quot;ChibiOS/ARM Configuration {#arm-configuration}&quot;"></a></h2><p>You&#39;ll need to determine which pins can be used for SPI -- as an example, STM32 parts generally have multiple SPI peripherals, labeled SPI1, SPI2, SPI3 etc.</p><p>To enable SPI, modify your board&#39;s <code>halconf.h</code> to enable SPI, then modify your board&#39;s <code>mcuconf.h</code> to enable the peripheral you&#39;ve chosen:</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-6RicS" id="tab-f45rQzW" checked="checked"><label for="tab-f45rQzW">halconf.h</label><input type="radio" name="group-6RicS" id="tab-qVI1Q4a"><label for="tab-qVI1Q4a">mcuconf.h</label></div><div class="blocks"><div class="language-c vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark has-focused-lines vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#pragma</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> once</span></span>\n<span class="line"></span>\n<span class="line has-focus"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> HAL_USE_SPI</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> TRUE</span></span>\n<span class=
const _hoisted_60 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_60);
}
const spi = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
spi as default
};