Skip to content

An async and no_std rust library for the wide-bandwidth haptic driver IC DA7280/DA7281/DA72782 from Renesas.

License

Notifications You must be signed in to change notification settings

thedevleon/da728x-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

da728x

Crate API

An async and no_std rust library for the wide-bandwidth haptic driver IC DA7280/DA7281/DA7282 from Renesas.

Supported ICs

  • DA7280
  • DA7281
  • DA7282

What works

  • CHIP_REV verification
  • Configuration with validation
  • Setting (resonant) frequency
  • Enable / disable playback
  • Reading and clearing system events and diagnostics
  • Driving an LRA in frequency track, wideband or custom waveform mode
  • DRO mode

What's missing

  • Testing of PWM_MODE
  • Uploading into the waveform memory and RTWM_MODE
  • GPI configuration and ETWM_MODE
  • Uploading a script (list of registers and values as exported by GUI)

Features

  • debug - Enable debug logging with the defmt crate

Usage

    use da728x::{DA728x, Variant};
    use da728x::config::{ActuatorConfig, ActuatorType, DeviceConfig, OperationMode, DrivingMode};

    // Setup I2C
    // let i2c = ...
    // let address = ...

    let mut haptics = DA728x::new(i2c, address, Variant::DA7280)
        .await
        .unwrap();

    // Values for the G1040003D LRA on the SparkFun board
    let actuator_config = ActuatorConfig {
        actuator_type: ActuatorType::LRA,
        nominal_max_mV: 2_106,
        absolute_max_mV: 2_260,
        max_current_mA: 165,
        impedance_mOhm: 13_800,
        frequency_Hz: 170,
    };

    // DRO Mode, which means we can set the amplitude via set_override_value()
    let device_config = DeviceConfig {
        operation_mode: OperationMode::DRO_MODE,
        driving_mode: DrivingMode::FREQUENCY_TRACK,
        acceleration: false,
        rapid_stop: false,
    };

    // Sets all registers as needed depending on the actuator type, operation mode and driving mode
    haptics.configure(actuator_config, device_config).await.unwrap();

    // Enables the Operation Mode (default is INACTIVE after configuration)
    haptics.enable().await.unwrap();

    loop {
        info!("100%");
        haptics.set_override_value(127).await.unwrap();
        Timer::after_millis(800).await;
        info!("33%");
        haptics.set_override_value(42).await.unwrap();
        Timer::after_millis(800).await;
        info!("0%");
        haptics.set_override_value(0).await.unwrap();
        Timer::after_millis(800).await;

        let status = haptics.get_status().await.unwrap();
        info!("Haptics Status: {:?}", status);
    }

Devkits

About

An async and no_std rust library for the wide-bandwidth haptic driver IC DA7280/DA7281/DA72782 from Renesas.

Topics

Resources

License

Stars

Watchers

Forks

Languages