Understand Wire Library

I am a bit confused about how the wire library is being used in this code portion.

In the following code, what is exactly "TwoWire *pwire = &WIRE" mean in the "begin" function under the class "ST25DV"?


#define SerialPort      Serial

#if defined(ARDUINO_B_L4S5I_IOT01A)
#define GPO_PIN RC5			 
#define LPD_PIN PE2		
#define SDA_PIN RC4			
#define SCL_PIN RC3			 

#define WireNFC MyWire
TwoWire MyWire(SDA_PIN, SCL_PIN);


#else
// Please define the pin and wire instance used for your board
#define GPO_PIN PE4
#define LPD_PIN PE2
#define SDA_PIN PB11
#define SCL_PIN PB10

#define WireNFC Wire // Default wire instance

#endif

#if !defined(GPO_PIN) || !defined(LPD_PIN)
#error define the pin and wire instance used for your board
#endif

  if(st25dv.begin(GPO_PIN, LPD_PIN, &WireNFC) == 0) {								
    SerialPort.println("System Init done!");
  } else {
    SerialPort.println("System Init failed!");
    while(1);
  }

Related code portion from header file:

class ST25DV {
  public:
    ST25DV(void);
    int begin(uint8_t gpo, uint8_t ldp, TwoWire *pwire = &WIRE);
    int writeURI(String protocol, String uri, String info);
    int readURI(String *s);

    void ST25DV_GPO_Init(void);
    void ST25DV_GPO_DeInit(void);
    uint8_t ST25DV_GPO_ReadPin(void);
    void ST25DV_LPD_Init(void);
    void ST25DV_LPD_DeInit(void);
    uint8_t ST25DV_LPD_ReadPin(void);
    void ST25DV_LPD_WritePin(uint8_t LpdPinState);
    void ST25DV_I2C_Init(void);
    void ST25DV_SelectI2cSpeed(uint8_t i2cspeedchoice);

    TwoWire *_pwire;

  private:
    uint8_t _gpo;
    uint8_t _lpd;
};

extern ST25DV st25dv; 	//Indication of function definitions in another file 
#endif

One of the function's parameters is a pointer to an object of type TwoWire. It's optional for the calling function to provide that argument. If it does not, the default value of the WIRE object's address is used. WIRE is a pre-defined TwoWire object in most (all?) Arduino cores.

Actually, Wire is the pre-defined TwoWire object, not WIRE. If THIS is the library you're using, then it defines WIRE thusly:

#if defined(ARDUINO_SAM_DUE)
#define WIRE Wire1
#else
#define WIRE Wire
#endif

Thanks a lot for the prompt response. I have a follow up query, by calling &WIRE in the function, is it navigating to SDA and SCL pins of that particular Arduino?

Probably. Some of the more sophisticated "Arduino" boards have a matrix that allows selecting between pins, but there's always a default. So, unless the library or user code changes it, the default will be used.

Got you! Thanks a lot!