<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SRC += snled27351-mono.c </span><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># For single-color</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SRC += snled27351.c </span><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># For RGB</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">I2C_DRIVER_REQUIRED = yes</span></span></code></pre></div><h2id="basic-configuration"tabindex="-1">Basic Configuration <aclass="header-anchor"href="#basic-configuration"aria-label="Permalink to "Basic Configuration {#basic-configuration}""></a></h2><p>Add the following to your <code>config.h</code>:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>SNLED27351_SDB_PIN</code></td><td><em>Not defined</em></td><td>The GPIO pin connected to the drivers' shutdown pins</td></tr><tr><td><code>SNLED27351_I2C_TIMEOUT</code></td><td><code>100</code></td><td>The I²C timeout in milliseconds</td></tr><tr><td><code>SNLED27351_I2C_PERSISTENCE</code></td><td><code>0</code></td><td>The number of times to retry I²C transmissions</td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_1</code></td><td><em>Not defined</em></td><td>The I²C address of driver 0</td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_2</code></td><td><em>Not defined</em></td><td>The I²C address of driver 1</td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_3</code></td><td><em>Not defined</em></td><td>The I²C address of driver 2</td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_4</code></td><td><em>Not defined</em></td><td>The I²C address of driver 3</td></tr></tbody></table><h3id="i2c-addressing"tabindex="-1">I²C Addressing <aclass="header-anchor"href="#i2c-addressing"aria-label="Permalink to "I²C Addressing {#i2c-addressing}""></a></h3><p>The SNLED27351 has four possible 7-bit I²C addresses, depending on how the <code>ADDR</code> pin is connected.</p><p>To configure this, set the <code>SNLED27351_I2C_ADDRESS_n</code> defines to one of the following in your <code>config.h</code>, where <em>n</em> denotes the driver index:</p><table><thead><tr><th>Define</th><th>Value</th></tr></thead><tbody><tr><td><code>SNLED27351_I2C_ADDRESS_GND</code></td><td><code>0x74</code></td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_SCL</code></td><td><code>0x75</code></td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_SDA</code></td><td><code>0x76</code></td></tr><tr><td><code>SNLED27351_I2C_ADDRESS_VDDIO</code></td><td><code>0x77</code></td></tr></tbody></table><h2id="arm-configuration"tabindex="-1">ARM/ChibiOS Configuration <aclass="header-anchor"href="#arm-configuration"aria-label="Permalink to "ARM/ChibiOS Configuration {#arm-configuration}""></a></h2><p>Depending on the ChibiOS board configuration, you may need to <ahref="./i2c#arm-configuration">enable and configure I²C</a> at the keyboard level.</p><h2id="led-mapping"tabindex="-1">LED Mapping <aclass="header-anchor"href="#led-mapping"aria-label="Permalink to "LED Mapping {#led-mapping}""></a></h2><p>In order to use this driver, each output must be mapped to an LED index, by adding the following to your <code><keyboardname>.c</code>:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> snled27351_led_t</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><spanstyle="--shiki-light:#E36209;--shiki-dark:#FFAB70;">g_snled27351_leds</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[SNLED27351_LED_COUNT] </span><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div><p>In this example, the red, green and blue channels for the first LED index on driver 0 all have their cathodes connected to the <code>CB1</code> pin, and their anodes on the <code>CA1</code>, <code>CA2</code> and <code>CA3</code> pins respectively.</p><p>For the single-color driver, the principle is the same, but there is only one channel:</p><divclass="language-c vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">c</span><preclass="shiki shiki-themes github-light github-dark vp-code"><code><spanclass="line"><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> snled27351_led_t</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><spanstyle="--shiki-light:#E36209;--shiki-dark:#FFAB70;">g_snled27351_leds</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[SNLED27351_LED_COUNT] </span><spanstyle="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
<spanclass="line"><spanstyle="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div><p>These values correspond to the register indices as shown in the datasheet on page 13.</p><h2id="api"tabindex="-1">API <aclass="header-anchor"href="#api"aria-label="Permalink to "API {#api}""></a></h2><h3id="api-snled27351-led-t"tabindex="-1"><code>struct snled27351_led_t</code><aclass="header-anchor"href="#api-snled27351-led-t"aria-label="Permalink to "`struct snled27351_led_t` {#api-snled27351-led-t}""></a></h3><p>Contains the PWM register addresses for a single RGB LED.</p><h4id="api-snled27351-led-t-members"tabindex="-1">Members <aclass="header-anchor"href="#api-snled27351-led-t-members"aria-label="Permalink to "Members {#api-snled27351-led-t-members}""></a></h4><ul><li><code>uint8_t driver</code><br> The driver index of the LED, from 0 to 3.</li><li><code>uint8_t r</code><br> The output PWM register address for the LED's red channel (RGB driver only).</li><li><code>uint8_t g</code><br> The output PWM register address for the LED's green channel (RGB driver only).</li><li><code>uint8_t b</code><br> The output PWM register address for the LED's blue channel (RGB driver only).</li><li><code>uint8_t v</code><br> The output PWM register address for the LED (single-color driver only).</li></ul><hr><h3id="api-snled27351-init"tabindex="-1"><code>void snled27351_init(uint8_t index)</code><aclass="header-anchor"href="#api-snled27351-init"aria-label="Permalink to "`void snled27351_init(uint8_t index)` {#api-snled27351-init}""></a></h3><p>Initialize the LED driver. This function should be called first.</p><h4id="api-snled27351-init-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-snled27351-init-arguments"aria-label="Permalink to "Arguments {#api-snled27351-init-arguments}""></a></h4><ul><li><code>uint8_t index</code><br> The driver index.</li></ul><hr><h3id="api-snled27351-write-register"tabindex="-1"><code>void snled27351_write_register(uint8_t index, uint8_t reg, uint8_t data)</code><aclass="header-anchor"href="#api-snled27351-write-register"aria-label="Permalink to "`void snled27351_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-snled27351-write-register}""></a></h3><p>Set the value of the given register.</p><h4id="api-snled27351-write-register-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-snled27351-write-register-arguments"aria-label="Permalink to "Arguments {#api-snled27351-write-register-arguments}""></a></h4><ul><li><code>uint8_t index</code><br> The driver index.</li><li><code>uint8_t reg</code><br> The register address.</li><li><code>uint8_t data</code><br> The value to set.</li></ul><hr><h3id="api-snled27351-select-page"tabindex="-1"><code>void snled27351_select_page(uint8_t index, uint8_t page)</code><aclass="header-anchor"href="#api-snled27351-select-page"aria-label="Permalink to "`void snled27351_select_page(uint8_t index, uint8_t page)` {#api-snled27351-select-page}""></a></h3><p>Change the current page for configuring the LED driver.</p><h4id="api-snled27351-select-page-arguments"tabindex="-1">Arguments <aclass="header-anchor"href="#api-snled27351-select-page-arguments"aria-label="Permalink to "Arguments {#api-snled27351-select-page-arguments}""></a></h4><ul><li><code>uint8_t index</code><br> The driver index.</li><li><code>uint8_t page</code><br> The page number to select.</li></ul><hr><h3id="api-snled27351-set-color"tabindex="-1"><code>void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)</code><aclass="header-anchor"href="#api-snled27351-set-color"aria-label="Permalink to "`void snled27351_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-snled27351-set-color}""></a></h3><p>Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call <code>snled27351_update