6#ifndef ZEPHYR_INCLUDE_DRIVERS_HAPTICS_CS40L5X_H_
7#define ZEPHYR_INCLUDE_DRIVERS_HAPTICS_CS40L5X_H_
176typedef struct device *(*cs40l5x_io_bus_get_device)(
const struct device *
const dev);
227#if CONFIG_HAPTICS_CS40L5X_I2C
234#if CONFIG_HAPTICS_CS40L5X_SPI
248#if CONFIG_HAPTICS_CS40L5X_I2C
252#if CONFIG_HAPTICS_CS40L5X_SPI
Main header file for GPIO driver API.
Main header file for I2C (Inter-Integrated Circuit) driver API.
Main header file for SPI (Serial Peripheral Interface) driver API.
struct device *(* cs40l5x_io_bus_get_device)(const struct device *const dev)
Return pointer to control port instance.
Definition cs40l5x.h:176
int cs40l5x_logger_get(const struct device *const dev, enum cs40l5x_logger_source source, enum cs40l5x_logger_source_type type, uint32_t *const value)
Get runtime haptics logging data for the specified logger source.
int cs40l5x_select_output(const struct device *const dev, const enum cs40l5x_bank bank, const uint8_t index)
Select haptic effect triggered via haptics_start_output().
int cs40l5x_calibrate(const struct device *const dev)
Run calibration to derive ReDC and F0 values and apply results for click compensation.
int(* cs40l5x_io_bus_write)(const struct device *const dev, uint32_t *const tx, const uint32_t len)
Function wrapper for i2c_write_dt() or spi_read_dt().
Definition cs40l5x.h:210
cs40l5x_bank
Wavetable sources for haptic effects.
Definition cs40l5x.h:49
cs40l5x_logger
Options for runtime haptics logging.
Definition cs40l5x.h:85
int cs40l5x_set_gain(const struct device *const dev, const uint8_t gain)
Configure gain for haptic effects triggered via haptics_start_output().
cs40l5x_attenuation
Attenuation options for GPIO-triggered haptic effects.
Definition cs40l5x.h:33
cs40l5x_logger_source_type
Type specification for runtime haptics logging sources.
Definition cs40l5x.h:107
int cs40l5x_configure_trigger(const struct device *const dev, const struct gpio_dt_spec *const gpio, const enum cs40l5x_bank bank, const uint8_t index, 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 enum cs40l5x_custom_index 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.
cs40l5x_trigger_edge
Options for edge-triggered haptics effects.
Definition cs40l5x.h:134
cs40l5x_logger_source
Options for runtime haptics logging sources.
Definition cs40l5x.h:96
cs40l5x_custom_index
Custom haptics source indices (0 or 1).
Definition cs40l5x.h:74
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_io_bus_read)(const struct device *const dev, const uint32_t addr, uint32_t *const rx, const uint32_t len)
Function wrapper for i2c_write_read_dt() or spi_read_dt().
Definition cs40l5x.h:198
bool(* cs40l5x_io_bus_is_ready)(const struct device *const dev)
Function wrapper for i2c_is_ready_dt() or spi_is_ready_dt().
Definition cs40l5x.h:186
int cs40l5x_upload_pwle(const struct device *const dev, const enum cs40l5x_custom_index index, const struct cs40l5x_pwle_section *const sections, const uint8_t num_sections)
Upload PWLE effect to the specified index.
@ CS40L5X_NO_BANK
Reserved for driver error handling.
Definition cs40l5x.h:53
@ CS40L5X_ROM_BANK
Playback from the pre-programmed ROM library.
Definition cs40l5x.h:50
@ CS40L5X_CUSTOM_BANK
Playback from custom haptics source programmed at runtime.
Definition cs40l5x.h:51
@ CS40L5X_BUZ_BANK
Playback from buzz source programmed at runtime.
Definition cs40l5x.h:52
@ CS40L5X_LOGGER_NO_CHANGE
Use to retrieve haptics logging status without updating.
Definition cs40l5x.h:88
@ CS40L5X_LOGGER_ENABLE
Enable runtime logging for the device.
Definition cs40l5x.h:87
@ CS40L5X_LOGGER_DISABLE
Disable runtime logging for the device.
Definition cs40l5x.h:86
@ CS40L5X_ATTENUATION_2DB
Configure haptic effect with 2 dB attenuation.
Definition cs40l5x.h:39
@ CS40L5X_ATTENUATION_6DB
Configure haptic effect with 6 dB attenuation.
Definition cs40l5x.h:35
@ CS40L5X_ATTENUATION_5DB
Configure haptic effect with 5 dB attenuation.
Definition cs40l5x.h:36
@ CS40L5X_ATTENUATION_4DB
Configure haptic effect with 4 dB attenuation.
Definition cs40l5x.h:37
@ CS40L5X_ATTENUATION_7DB
Configure haptic effect with 7 dB attenuation.
Definition cs40l5x.h:34
@ CS40L5X_ATTENUATION_1DB
Configure haptic effect with 1 dB attenuation.
Definition cs40l5x.h:40
@ CS40L5X_ATTENUATION_0DB
Configure haptic effect with no attenuation.
Definition cs40l5x.h:41
@ CS40L5X_ATTENUATION_3DB
Configure haptic effect with 3 dB attenuation.
Definition cs40l5x.h:38
@ CS40L5X_LOGGER_MAX
Maximum value sampled for a logger source.
Definition cs40l5x.h:109
@ CS40L5X_LOGGER_MEAN
Mean value sampled for a logger source.
Definition cs40l5x.h:110
@ CS40L5X_LOGGER_MIN
Minimum value sampled for a logger source.
Definition cs40l5x.h:108
@ CS40L5X_RISING_EDGE
Configure a rising-edge haptic effect.
Definition cs40l5x.h:135
@ CS40L5X_FALLING_EDGE
Configure a falling-edge haptic effect.
Definition cs40l5x.h:136
@ CS40L5X_LOGGER_BEMF
Back EMF (SVC) in signed Q0.23 format (full scale is 24 V).
Definition cs40l5x.h:97
@ CS40L5X_LOGGER_VMON
Output voltage in signed Q0.23 format (full scale is 24 V).
Definition cs40l5x.h:99
@ CS40L5X_LOGGER_VBST
Boost voltage in unsigned Q0.24 format (full scale is 14 V).
Definition cs40l5x.h:98
@ CS40L5X_CUSTOM_0
Custom haptics source at index 0.
Definition cs40l5x.h:75
@ CS40L5X_CUSTOM_1
Custom haptics source at index 1.
Definition cs40l5x.h:76
@ CS40L5X_NUM_CUSTOM_EFFECTS
Maximum number of custom haptics effects.
Definition cs40l5x.h:77
void(* haptics_error_callback_t)(const struct device *dev, const uint32_t errors, void *const user_data)
Callback function for error interrupt.
Definition haptics.h:68
Main header file for haptics driver API.
__INTPTR_TYPE__ off_t
Definition types.h:36
#define bool
Definition stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT8_TYPE__ int8_t
Definition stdint.h:72
Control port I/O functions.
Definition cs40l5x.h:216
cs40l5x_io_bus_get_device get_device
< Get control device instance for PM runtime usage
Definition cs40l5x.h:218
cs40l5x_io_bus_is_ready is_ready
Read from the device.
Definition cs40l5x.h:220
cs40l5x_io_bus_read read
Write to the device.
Definition cs40l5x.h:222
cs40l5x_io_bus_write write
Definition cs40l5x.h:224
Structure to store control port devices.
Definition cs40l5x.h:247
Calibration data for click compensation.
Definition cs40l5x.h:61
uint32_t f0
Definition cs40l5x.h:65
uint32_t redc
< Coil DC resistance in signed Q6.17 format (Ohms * (24 / 2.9))
Definition cs40l5x.h:63
CS40L5x configuration structure for a device instance.
Definition cs40l5x.h:261
const struct device *const dev
< Pointer to CS40L5x device instance
Definition cs40l5x.h:263
const struct device * flash
Optional flash register offset, configurable via devicetree property 'flash-offset'.
Definition cs40l5x.h:279
struct cs40l5x_data *const data
Logger configuration for instance-based logging.
Definition cs40l5x.h:265
struct gpio_dt_spec reset_gpio
Optional GPIO for hardware and DSP interrupts.
Definition cs40l5x.h:273
struct gpio_dt_spec interrupt_gpio
Optional GPIOs for edge-triggered haptic effects.
Definition cs40l5x.h:275
const off_t flash_offset
Boost setting, configurable via devicetree property 'external-boost'.
Definition cs40l5x.h:281
const struct cs40l5x_bus bus
Control port I/O functions.
Definition cs40l5x.h:269
struct cs40l5x_trigger_gpios trigger_gpios
Optional flash storage, configurable via devicetree property 'flash-storage'.
Definition cs40l5x.h:277
const struct cs40l5x_bus_io *const bus_io
Required GPIO for hardware resets.
Definition cs40l5x.h:271
const struct device *const external_boost
Definition cs40l5x.h:283
LOG_INSTANCE_PTR_DECLARE(log)
Control port devices.
CS40L5x data structure for a device instance.
Definition cs40l5x.h:289
struct k_sem calibration_semaphore
F0 and ReDC data derived from calibration.
Definition cs40l5x.h:311
struct k_work_delayable interrupt_worker
Callback handler for trigger logging.
Definition cs40l5x.h:303
struct gpio_callback interrupt_callback
Worker for debounced interrupt processing.
Definition cs40l5x.h:301
uint8_t buf_trigger_history[CONFIG_HAPTICS_CS40L5X_METADATA_CACHE_LEN]
Upload status for custom effects at indices 0 and 1.
Definition cs40l5x.h:323
struct gpio_callback trigger_callback
Application-provided callback to recover from fatal hardware errors.
Definition cs40l5x.h:305
struct cs40l5x_calibration calibration
Playback command for mailbox-triggered haptic effects.
Definition cs40l5x.h:313
haptics_error_callback_t error_callback
Application-provided user data for callback context.
Definition cs40l5x.h:307
struct ring_buf rb_mailbox_history
Ring buffer to cache trigger playback history.
Definition cs40l5x.h:317
const struct device *const dev
< Pointer to CS40L5x device instance
Definition cs40l5x.h:291
void * user_data
Semaphore used to sequence the calibration routine.
Definition cs40l5x.h:309
int effects_in_flight
Definition cs40l5x.h:327
uint8_t buf_mailbox_history[CONFIG_HAPTICS_CS40L5X_METADATA_CACHE_LEN]
Ring buffer storage for cached trigger playback history.
Definition cs40l5x.h:321
uint8_t rev_id
Callback handler for interrupt processing.
Definition cs40l5x.h:299
uint32_t dev_id
Revision ID corresponding to the silicon variant.
Definition cs40l5x.h:297
uint32_t output
Ring buffer to cache mailbox playback history.
Definition cs40l5x.h:315
bool custom_effects[CS40L5X_NUM_CUSTOM_EFFECTS]
Number of haptic effects playing or suspended.
Definition cs40l5x.h:325
struct ring_buf rb_trigger_history
Ring buffer storage for cached mailbox playback history.
Definition cs40l5x.h:319
struct k_mutex lock
Device ID corresponding to the part number.
Definition cs40l5x.h:295
const struct cs40l5x_config *const config
Lock to deconflict haptic playback, device calibration, and configuration changes.
Definition cs40l5x.h:293
PWLE section definition.
Definition cs40l5x.h:118
uint16_t frequency
Section level in unsigned Q0.11 format.
Definition cs40l5x.h:122
uint8_t flags
Definition cs40l5x.h:126
uint16_t level
Section flags in unsigned Q4.0 format.
Definition cs40l5x.h:124
uint16_t duration
< Section duration in unsigned Q14.2 format (time) or Q16.0 format (half-cycles)
Definition cs40l5x.h:120
Structure to store GPIO trigger configurations.
Definition cs40l5x.h:142
uint8_t address
Definition cs40l5x.h:150
uint8_t index
Attenuation to be applied to haptic effect.
Definition cs40l5x.h:146
int attenuation
Offset register address that stores the GPIO trigger configuration.
Definition cs40l5x.h:148
enum cs40l5x_bank bank
< Wavetable source for desired haptic effect
Definition cs40l5x.h:144
Structure to store and handle trigger GPIOs.
Definition cs40l5x.h:156
struct cs40l5x_trigger_config * rising_edge
Trigger configurations for falling-edge events.
Definition cs40l5x.h:162
bool * ready
Definition cs40l5x.h:166
const uint8_t num_gpio
Trigger configurations for rising-edge events.
Definition cs40l5x.h:160
struct gpio_dt_spec * gpio
< Array of GPIOs provided via devicetree property 'trigger-gpios'
Definition cs40l5x.h:158
struct cs40l5x_trigger_config * falling_edge
GPIO statuses.
Definition cs40l5x.h:164
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
GPIO callback structure.
Definition gpio.h:748
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
Complete I2C DT information.
Definition i2c.h:78
Mutex Structure.
Definition kernel.h:3404
Semaphore structure.
Definition kernel.h:3609
A structure used to submit work after a delay.
Definition kernel.h:4533
A structure to represent a ring buffer.
Definition ring_buffer.h:50
Complete SPI DT information.
Definition spi.h:541