Hi, I am trying to perform a read of 4 bytes from my Honeywell pressure sensor ~ to do that I am performing this operation -
I2C pressureread(PB_8,PB_9);
uint32_t readpressure(){ uint8_t parray[4]; uint8_t status; pressureread.start(); // to start the i2c communication with the sensor we send the start bit pressureread.read(0x31, &parray[0], 4, false); status = parray[0]; if((status & 0b00100000) != 0){ return -1; } else { return(parray[1]<<16|parray[2]<<8|parray[3]); } }
However running this I get this error can someone help ~
*no instance of overloaded function “mbed::I2C::read” matches the argument list – argument types are: (int, uint8_t , int, bool) – object type is: mbed::I2C
Thank you for your quick reply. I have switched the ports in my code as you said.
However, I am still getting the same error regarding the read function.
I checked the I2C.cpp file and in that the i2c read function has been defined as -
int I2C::read(int address, char *data, int length, bool repeated)
So my understanding is that the i2c read function expects a pointer to a character whereas the variable in my code(&parray[0]) is a pointer to an uint8_t(unsigned char) type.
So maybe I could convert the whole thing into a char array instead of uint_8t. As in instead of uint_8t parray[4] I could declare it as a char parray[4]