0

convert Adafruit library c++ to c
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

convert Adafruit library c++ to c

by Joudi on Mon Feb 11, 2019 2:07 pm

Hi,

I'm trying to convert Adafruit library from c++ to c. The sensor name is SI1145 and i have a problem with this part.

in .cpp file:
Code: Select all | TOGGLE FULL SIZE
uint16_t _read16(uint8_t a) {
  uint16_t ret;

  Wire.beginTransmission(_addr); // start transmission to device
  Wire.write(a); // sends register address to read from
  Wire.endTransmission(); // end transmission
 
  Wire.requestFrom(_addr, (uint8_t)2);// send data n-bytes read
  ret = Wire.read(); // receive DATA
  ret |= (uint16_t)Wire.read() << 8; // receive DATA

  return ret;
}


in .h file the parameters are a little bit different.
Code: Select all | TOGGLE FULL SIZE
uint16_t _read16(uint8_t addr);


I don't really get why one says "a" and the other says "address". How do I properly convert the parameters?

Joudi
 
Posts: 1
Joined: Mon Feb 11, 2019 1:51 pm

Re: convert Adafruit library c++ to c

by adafruit_support_bill on Mon Feb 11, 2019 2:11 pm

The .h file is just defining the call signature for that function. The number, type and order of the parameters are important. The parameter names are not.

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.