1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * 4094332d3Sopenharmony_ci * HDF is dual licensed: you can use it either under the terms of 5094332d3Sopenharmony_ci * the GPL, or the BSD license, at your option. 6094332d3Sopenharmony_ci * See the LICENSE file in the root of this repository for complete details. 7094332d3Sopenharmony_ci */ 8094332d3Sopenharmony_ci 9094332d3Sopenharmony_ci#ifndef DRV2605L_DRIVER_H 10094332d3Sopenharmony_ci#define DRV2605L_DRIVER_H 11094332d3Sopenharmony_ci 12094332d3Sopenharmony_ci#include "hdf_device_desc.h" 13094332d3Sopenharmony_ci 14094332d3Sopenharmony_ci#define I2C_READ_MSG_NUM 2 15094332d3Sopenharmony_ci#define I2C_READ_MSG_ADDR_IDX 0 16094332d3Sopenharmony_ci#define I2C_READ_MSG_VALUE_IDX 1 17094332d3Sopenharmony_ci 18094332d3Sopenharmony_ci#define DRV2605L_ADDR_WIDTH_1_BYTE 1 // 8 bit 19094332d3Sopenharmony_ci#define DRV2605L_ADDR_WIDTH_2_BYTE 2 // 16 bit 20094332d3Sopenharmony_ci 21094332d3Sopenharmony_ci#define I2C_WRITE_MSG_NUM 1 22094332d3Sopenharmony_ci#define I2C_REG_BUF_LEN 4 23094332d3Sopenharmony_ci#define I2C_BYTE_MASK 0xFF 24094332d3Sopenharmony_ci#define I2C_BYTE_OFFSET 8 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_ci#define DRV2605_REG_MODE 0x01 // Mode register 27094332d3Sopenharmony_ci#define DRV2605_MODE_REALTIME 0x05 // Real-time playback (RTP) mode 28094332d3Sopenharmony_ci#define DRV2605_MODE_STANDBY 0x45 // Software standby mode 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_ci#define DRV2605_REG_CONTROL3 0x1D // Control3 Register 31094332d3Sopenharmony_ci#define DRV2605_MODE_OPEN_LOOP 0xA9 // Open Loop 32094332d3Sopenharmony_ci 33094332d3Sopenharmony_ci#define DRV2605_REG_FEEDBACK 0x1A // Feedback control register 34094332d3Sopenharmony_ci#define DRV2605_MODE_LRA 0xB6 // LRA Mode 35094332d3Sopenharmony_ci 36094332d3Sopenharmony_ci#define DRV2605_REG_RTPIN 0x02 // Real-time playback input register 37094332d3Sopenharmony_ci#define DRV2605_REG_LRARESON 0x20 // LRA open loop period 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci#define INTENSITY_MAPPING_VALUE(value) {0XA8 + ((value) * (0XFF - 0XA8)) / 100} 40094332d3Sopenharmony_ci 41094332d3Sopenharmony_ci#define FREQUENCY_MAPPING_VALUE(value) {1000000 / (98 * (value))} 42094332d3Sopenharmony_ci 43094332d3Sopenharmony_cienum Drv2605lConfigValueIndex { 44094332d3Sopenharmony_ci DRV2605L_ADDR_INDEX, 45094332d3Sopenharmony_ci DRV2605L_VALUE_INDEX, 46094332d3Sopenharmony_ci DRV2605L_VALUE_BUTT, 47094332d3Sopenharmony_ci}; 48094332d3Sopenharmony_ci 49094332d3Sopenharmony_cistruct Drv2605lDriverData { 50094332d3Sopenharmony_ci struct IDeviceIoService ioService; 51094332d3Sopenharmony_ci struct HdfDeviceObject *device; 52094332d3Sopenharmony_ci const struct DeviceResourceNode *root; 53094332d3Sopenharmony_ci struct VibratorCfgData *drv2605lCfgData; 54094332d3Sopenharmony_ci}; 55094332d3Sopenharmony_ci 56094332d3Sopenharmony_ci#endif /* DRV2605L_DRIVER_H */