|
Zephyr Project API 4.4.99
A Scalable Open Source RTOS
|
CS40L5x Haptic Driver for LRA and VCM. More...
Files | |
| file | cs40l5x.h |
| Header file providing the API for the CS40L5x haptic driver. | |
Data Structures | |
| struct | cs40l5x_pwle_section |
| PWLE section definition. More... | |
Enumerations | |
| enum | cs40l5x_attenuation { CS40L5X_ATTENUATION_7DB = -7 , CS40L5X_ATTENUATION_6DB , CS40L5X_ATTENUATION_5DB , CS40L5X_ATTENUATION_4DB , CS40L5X_ATTENUATION_3DB , CS40L5X_ATTENUATION_2DB , CS40L5X_ATTENUATION_1DB , CS40L5X_ATTENUATION_0DB } |
| Attenuation options for triggered haptic effects. More... | |
| enum | cs40l5x_source { CS40L5X_SOURCE_BUZ = HAPTICS_SOURCE_PRIV_START , CS40L5X_SOURCE_RTH } |
| Wavetable sources for haptic effects. More... | |
| enum | cs40l5x_trigger_edge { CS40L5X_RISING_EDGE , CS40L5X_FALLING_EDGE } |
| Options for edge-triggered haptics effects. More... | |
Functions | |
| int | cs40l5x_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 | cs40l5x_configure_trigger (const struct device *const dev, const struct gpio_dt_spec *const gpio, const enum haptics_source src, const union haptics_config *const cfg, const enum cs40l5x_attenuation attenuation, const enum cs40l5x_trigger_edge edge) |
| Configure edge-triggered haptic effect. | |
| int | cs40l5x_upload_pcm (const struct device *const dev, const int index, const uint16_t redc, const uint16_t f0, const int8_t *const samples, const uint16_t num_samples) |
| Upload PCM effect to the specified index. | |
| int | cs40l5x_upload_pwle (const struct device *const dev, const int index, const struct cs40l5x_pwle_section *const sections, const uint8_t num_sections) |
| Upload PWLE effect to the specified index. | |
CS40L5x Haptic Driver for LRA and VCM.
| enum cs40l5x_attenuation |
#include <cs40l5x.h>
Attenuation options for triggered haptic effects.
Provide to cs40l5x_configure_trigger().
| enum cs40l5x_source |
#include <cs40l5x.h>
Wavetable sources for haptic effects.
| Enumerator | |
|---|---|
| CS40L5X_SOURCE_BUZ | Playback from the buzz library. |
| CS40L5X_SOURCE_RTH | Playback from the runtime library. |
| enum cs40l5x_trigger_edge |
#include <cs40l5x.h>
Options for edge-triggered haptics effects.
Provide to cs40l5x_configure_trigger() to specify the edge for haptic effects.
| Enumerator | |
|---|---|
| CS40L5X_RISING_EDGE | Configure a rising-edge haptic effect. |
| CS40L5X_FALLING_EDGE | Configure a falling-edge haptic effect. |
| int cs40l5x_configure_buzz | ( | const struct device *const | dev, |
| const uint32_t | frequency, | ||
| const uint8_t | level, | ||
| const uint32_t | duration ) |
#include <cs40l5x.h>
Configure ROM buzz for haptic playback.
With large amplitudes and insufficient power (e.g., in the case of internal boost configurations), it's possible to induce boost errors.
| [in] | dev | Pointer to the device structure for haptic device instance |
| [in] | frequency | Frequency of haptic effect in Hz (default: 0xF0) |
| [in] | level | Amplitude of haptic effect, where UINT8_MAX is 100% (default: 0x1B) |
| [in] | duration | Playback duration in milliseconds, where 0 is indefinite (default: 0x32) |
| -EIO | A control port transaction failed. |
| int cs40l5x_configure_trigger | ( | const struct device *const | dev, |
| const struct gpio_dt_spec *const | gpio, | ||
| const enum haptics_source | src, | ||
| const union haptics_config *const | cfg, | ||
| const enum cs40l5x_attenuation | attenuation, | ||
| const enum cs40l5x_trigger_edge | edge ) |
#include <cs40l5x.h>
Configure edge-triggered haptic effect.
| [in] | dev | Pointer to the device structure for haptic device instance |
| [in] | gpio | Pointer to the device structure for the GPIO used as the trigger source |
| [in] | src | Playback source (of type haptics_source) |
| [in] | cfg | Source configuration (of type haptics_config) |
| [in] | attenuation | Attenuation in dB for desired haptic effect |
| [in] | edge | Specify edge (rising or falling) to trigger haptic effects |
| -EINVAL | Invalid wavetable source and index provided (e.g., index out of bounds). |
| -EIO | A control port transaction failed. |
| int cs40l5x_upload_pcm | ( | const struct device *const | dev, |
| const int | index, | ||
| const uint16_t | redc, | ||
| const uint16_t | f0, | ||
| const int8_t *const | samples, | ||
| const uint16_t | num_samples ) |
#include <cs40l5x.h>
Upload PCM effect to the specified index.
| [in] | dev | Pointer to the device structure for haptic device instance |
| [in] | index | Wavetable index |
| [in] | redc | ReDC compensation in unsigned Q5.7 format | redc * (24 / 2.9) |
| [in] | f0 | F0 compensation in unsigned Q9.3 format | (f0 - 50) * 8 |
| [in] | samples | Array of signed 8-bit PCM samples |
| [in] | num_samples | Number of PCM samples |
| -EINVAL | Invalid index provided (e.g., index out of bounds). |
| -EIO | A control port transaction failed. |
| int cs40l5x_upload_pwle | ( | const struct device *const | dev, |
| const int | index, | ||
| const struct cs40l5x_pwle_section *const | sections, | ||
| const uint8_t | num_sections ) |
#include <cs40l5x.h>
Upload PWLE effect to the specified index.
| [in] | dev | Pointer to the device structure for haptic device instance |
| [in] | index | Wavetable index |
| [in] | sections | Array of cs40l5x_pwle_section |
| [in] | num_sections | Number of PWLE sections |
| -EINVAL | Invalid index provided (e.g., index out of bounds). |
| -EIO | A control port transaction failed. |