Other Parts Discussed in Thread: DRV2605L
Hi,
i have been working to generate Haptic feedback using DRV2605l-Q1, but not able to get the feedback. i have attached my code written according to the instructions provided in the device datasheet.
Please check it once and let me know what need to be done to get the haptic feedback. waiting for your swift support, now the project is in critical stage, please take it on priority.
Thanks,
Sumit.
#define DRV2605L_Q1_DEVICE_ADDR 0x5A /*uint8_t MODE_reg[2]; struct RegAdd_Data { uint8_t Reg_Add; uint8_t Data; };*/ //struct RegAdd_Data InitBuf[]{ uint8_t Mode[2] = {0x01,0x01}; /*Mode selection and Standby clear*/ uint8_t Lib_Select[2] = {0x03,0x02}; /*Selecting library TS2200 Library B*/ uint8_t Feedback_Ctrl[2] = {0x1A,0xA8}; /*Feedback Control*/ uint8_t R_Volt[2] = {0x16,0x8E}; /*Rated voltage for closed loop ERM*/ uint8_t OD_Clamp[2] = {0x17,0x8C}; /*OD_Clamp for closed loop ERM*/ uint8_t Auto_calib_Time[2] = {0x1E,0x30}; /*Auto calibration time*/ uint8_t Drive_time[2] = {0x1B,0x1F}; /*Drive time*/ uint8_t SamBlanIDISS_Time[2] = {0x1C,0x35}; /*Sample, Blanking and IDISS time*/ uint8_t GO_Bit[2] = {0x0C,0x01}; /*GO Bit*/ uint8_t InitDataLength = 2; uint8_t Mode_PWM[2] = {0x01,0x03}; /*Mode selection and Standby set*/ uint8_t Analog_Input[2] = {0x1D,0x02}; /*Control register 3*/ uint8_t Mode_RTP[2] = {0x01,0x05}; /*Mode selection and Standby set*/ uint8_t Data_Format_RTP[2] = {0x1D,0x01}; /*selecting data format as unsigned*/ uint8_t Input_RTP[2] = {0x02,0x3F}; /*Providing RTP input*/ void DRV2605L_Q1_Init(void) { //crDELAY( xHandle, 250 ); PORT_PinSet(PORT_PIN_PB23); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Mode, InitDataLength); AutoCalibration(); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Lib_Select, InitDataLength); PORT_PinClear(PORT_PIN_PB23); } void AutoCalibration(void) { SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Feedback_Ctrl, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, R_Volt, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, OD_Clamp, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Auto_calib_Time, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Drive_time, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, SamBlanIDISS_Time, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, GO_Bit, InitDataLength); } void Play_PWM(void) { //DRV2605L_Q1_Init(); PORT_PinSet(PORT_PIN_PB23); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Mode_PWM, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Analog_Input, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, R_Volt, InitDataLength); PORT_PinClear(PORT_PIN_PB23); } void Play_RTP(void) { DRV2605L_Q1_Init(); PORT_PinSet(PORT_PIN_PB23); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Mode_RTP, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Data_Format_RTP, InitDataLength); SERCOM2_I2C_Write(DRV2605L_Q1_DEVICE_ADDR, Input_RTP, InitDataLength); PORT_PinClear(PORT_PIN_PB23); } IIC function definition: bool SERCOM2_I2C_Write(uint16_t address, uint8_t* wrData, uint32_t wrLength) { return SERCOM2_I2C_XferSetup(address, wrData, wrLength, NULL, 0, false, false); }