Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Public API for CS40L26 haptic driver. More...

#include <zephyr/kernel.h>

Go to the source code of this file.

Enumerations

enum  cs40l26_bank { CS40L26_ROM_BANK , CS40L26_BUZ_BANK , CS40L26_NO_BANK }
 Wavetable sources for effects. More...

Functions

int cs40l26_calibrate (const struct device *const dev)
 Run calibration to derive ReDC and F0 values and apply results for click compensation.
int cs40l26_configure_buzz (const struct device *const dev, const uint32_t frequency, const uint8_t level, const uint32_t duration)
 Configure ROM buzz for haptic playback.
int cs40l26_select_output (const struct device *const dev, const enum cs40l26_bank bank, const uint16_t index)
 Select haptic effect triggered via haptics_start_output().
int cs40l26_set_gain (const struct device *const dev, const uint8_t gain)
 Configure gain for haptic effects triggered via haptics_start_output().

Detailed Description

Public API for CS40L26 haptic driver.

Enumeration Type Documentation

◆ cs40l26_bank

Wavetable sources for effects.

Provide to cs40l26_select_output().

Enumerator
CS40L26_ROM_BANK 

Playback from the pre-programmed ROM library.

CS40L26_BUZ_BANK 

Playback from buzz source programmed at runtime.

CS40L26_NO_BANK 

Reserved for driver error handling.

Function Documentation

◆ cs40l26_calibrate()

int cs40l26_calibrate ( const struct device *const dev)

Run calibration to derive ReDC and F0 values and apply results for click compensation.

Parameters
[in]devPointer to the device structure for haptic device instance
Return values
0if success
<0if failed

◆ cs40l26_configure_buzz()

int cs40l26_configure_buzz ( const struct device *const dev,
const uint32_t frequency,
const uint8_t level,
const uint32_t duration )

Configure ROM buzz for haptic playback.

With large amplitudes and insufficient power, it's possible to reach the current limit.

Parameters
[in]devPointer to the device structure for haptic device instance
[in]frequencyFrequency of haptic effect in Hz (default: 0xA5)
[in]levelAmplitude of haptic effect, where UINT8_MAX is 100% (default: 0x40)
[in]durationPlayback duration in units of 4 milliseconds
Return values
0if success
<0if failed

◆ cs40l26_select_output()

int cs40l26_select_output ( const struct device *const dev,
const enum cs40l26_bank bank,
const uint16_t index )

Select haptic effect triggered via haptics_start_output().

Parameters
[in]devPointer to the device structure for haptic device instance
[in]bankRefer to cs40l26_bank
[in]indexWavetable index for desired haptic effect
Return values
0if successful
<0if failed

◆ cs40l26_set_gain()

int cs40l26_set_gain ( const struct device *const dev,
const uint8_t gain )

Configure gain for haptic effects triggered via haptics_start_output().

Parameters
[in]devPointer to the device structure for haptic device instance
[in]gainGain setting (valid values between 0 and 100)
Return values
0if successful
<0if failed