DRV2605 driver for ZMK

June 29, 2024 ยท View on GitHub

This module exposes DRV2605 internal interrupt trigger instruction set via Zephyr's sensor_driver_api.

This module was developed and tested on adafruit-drv2605-haptic-controller-breakout with this X-Axis LRA (Linear Resonant Actuator).

Example is available at here in zmk-output-behavior-listener.

Installation

Include this project on ZMK's west manifest in config/west.yml:

manifest:
  remotes:
    #...
    - name: badjeff
      url-base: https://github.com/badjeff
    #...
  projects:
    #...
    - name: zmk-drv2605-driver
      remote: badjeff
      revision: main
    #...
  self:
    path: config

Update board.overlay adding the necessary bits (update the pins for your board accordingly):

&pinctrl {
    i2c0_default: i2c0_default {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 9)>,
                    <NRF_PSEL(TWIM_SCL, 0, 10)>;
        };
    };

    i2c0_sleep: i2c0_sleep {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 9)>,
                    <NRF_PSEL(TWIM_SCL, 0, 10)>;
            low-power-enable;
        };
    };
};

&i2c0 {
    status = "okay";
    compatible = "nordic,nrf-twim";
    pinctrl-0 = <&i2c0_default>;
    pinctrl-1 = <&i2c0_sleep>;
    pinctrl-names = "default", "sleep";

    drv2605_0: drv2605@5a {
        compatible = "ti,drv2605";
        reg = <0x5a>;

        /* Library to use, 0 = Empty, 1-5 are ERM, 6 is LRA. */
        library = <6>;

        /* switch to standby mode after idling for 1000ms */
        standby-ms = <1000>;
    };
};

Enable the driver config in <shield>.config file (read the Kconfig file to find out all possible options):

# Enable debug logging
CONFIG_DRV2605_LOG_LEVEL_DBG=y