How to use the second I2C on ARDUINO DUE in this code

Hi, I tried to control two LRA with DRV2605 by Arduino DUE, and the manufacture provides an example code as below:
#include <Wire.h>
#include “Adafruit_DRV2605.h”

Adafruit_DRV2605 drv;

void setup() {
Serial.begin(9600);
Serial.println(“DRV test”);
drv.begin();

drv.selectLibrary(1);

// I2C trigger by sending ‘go’ command
// default, internal trigger when sending GO command
drv.setMode(DRV2605_MODE_INTTRIG);
}

uint8_t effect = 1;

void loop() {
Serial.print(“Effect #”); Serial.println(effect);

// set the effect to play
drv.setWaveform(0, effect); // play effect
drv.setWaveform(1, 0); // end waveform

// play the effect!
drv.go();

// wait a bit
delay(500);

effect++;
if (effect > 117) effect = 1;
}
This code works on ports SDA and SCL, how can achieve it on ports SDA1 and SCL1. In addition, I want to use these two I2C ports to control two LRA asynchronously, what should I do?

You would probably need to dig into the drv library and change the Wire calls to Wire1. There is a way using a define to do it if the code is being compiled for a Due.

// change this
Wire.begin();
// to this
Wire1.begin();

Thank you for the replay. I have read the library as below, but there is no wire.begin (). I tried to solve this problem before, but this library is a kind of C language.
#if ARDUINO >= 100
#else
#include “WProgram.h”
#endif

#include <Wire.h>

#define DRV2605_ADDR 0x5A

#define DRV2605_REG_STATUS 0x00
#define DRV2605_REG_MODE 0x01
#define DRV2605_MODE_INTTRIG 0x00
#define DRV2605_MODE_EXTTRIGEDGE 0x01
#define DRV2605_MODE_EXTTRIGLVL 0x02
#define DRV2605_MODE_PWMANALOG 0x03
#define DRV2605_MODE_AUDIOVIBE 0x04
#define DRV2605_MODE_REALTIME 0x05
#define DRV2605_MODE_DIAGNOS 0x06
#define DRV2605_MODE_AUTOCAL 0x07

#define DRV2605_REG_RTPIN 0x02
#define DRV2605_REG_LIBRARY 0x03
#define DRV2605_REG_WAVESEQ1 0x04
#define DRV2605_REG_WAVESEQ2 0x05
#define DRV2605_REG_WAVESEQ3 0x06
#define DRV2605_REG_WAVESEQ4 0x07
#define DRV2605_REG_WAVESEQ5 0x08
#define DRV2605_REG_WAVESEQ6 0x09
#define DRV2605_REG_WAVESEQ7 0x0A
#define DRV2605_REG_WAVESEQ8 0x0B

#define DRV2605_REG_GO 0x0C
#define DRV2605_REG_OVERDRIVE 0x0D
#define DRV2605_REG_SUSTAINPOS 0x0E
#define DRV2605_REG_SUSTAINNEG 0x0F
#define DRV2605_REG_BREAK 0x10
#define DRV2605_REG_AUDIOCTRL 0x11
#define DRV2605_REG_AUDIOLVL 0x12
#define DRV2605_REG_AUDIOMAX 0x13
#define DRV2605_REG_RATEDV 0x16
#define DRV2605_REG_CLAMPV 0x17
#define DRV2605_REG_AUTOCALCOMP 0x18
#define DRV2605_REG_AUTOCALEMP 0x19
#define DRV2605_REG_FEEDBACK 0x1A
#define DRV2605_REG_CONTROL1 0x1B
#define DRV2605_REG_CONTROL2 0x1C
#define DRV2605_REG_CONTROL3 0x1D
#define DRV2605_REG_CONTROL4 0x1E
#define DRV2605_REG_VBAT 0x21
#define DRV2605_REG_LRARESON 0x22

class Adafruit_DRV2605 {
public:

Adafruit_DRV2605(void);
boolean begin(void);

void writeRegister8(uint8_t reg, uint8_t val);
uint8_t readRegister8(uint8_t reg);
void setWaveform(uint8_t slot, uint8_t w);
void selectLibrary(uint8_t lib);
void go(void);
void setMode(uint8_t mode);

private:

};

Yes there are. They are in Adafruit_DRV2605.cpp. The Wire calls are in the last two functions of that file.

uint8_t Adafruit_DRV2605::readRegister8(uint8_t reg) {
  uint8_t x ;
   // use i2c
    Wire.beginTransmission(DRV2605_ADDR);
    Wire.write((byte)reg);
    Wire.endTransmission();
    Wire.requestFrom((byte)DRV2605_ADDR, (byte)1);
    x = Wire.read();

  //  Serial.print("$"); Serial.print(reg, HEX); 
  //  Serial.print(": 0x"); Serial.println(x, HEX);
  
  return x;
}

void Adafruit_DRV2605::writeRegister8(uint8_t reg, uint8_t val) {
   // use i2c
    Wire.beginTransmission(DRV2605_ADDR);
    Wire.write((byte)reg);
    Wire.write((byte)val);
    Wire.endTransmission();
}

edit:...and in the begin function above those.

boolean Adafruit_DRV2605::begin() {
  Wire.begin();

You must change those to Wire1 or use a define at the top of that file.

#define Wire Wire1

This is how the rest of Adafruit's libraries change the I2C calls.

thank you so much, this works!