主题中讨论的其他器件: DRV2605L
您好!
我一直在使用 DRV2605l-Q1生成触觉反馈、但无法获得反馈。 我已经附上了根据器件数据表中提供的说明编写的代码。
请检查一次、让我知道需要执行哪些操作才能获得触觉反馈。 等待您的快速支持、现在该项目正处于关键阶段、请优先考虑它。
谢谢。
总结。
#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); }