Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
Problem using a constructor for the accelerometer predefined mma845x library
Hello, I'm trying to use a library for the mma8452 accelerometer. The library is mma845x by Sam Grove. The code gives me an error when trying to define the constructor for the accelerometer.
This is how I define the accelerometer in the main method:
I2C i2c (PA_10,PA_9); MMA845x accel (i2c, 0x1D);
This is the constructor in library cpp:
MMA845x::MMA845x(I2C &i2c, MMA845x_SA0 const i2c_addr) { _i2c = &i2c; _i2c_addr = (0x1c << 2) | (i2c_addr << 0x1);
return; }
This is the constructor definitions in the library.h: class MMA845x { enum MMA845x_SA0 { SA0_VSS = 0, /*!< SA0 connected to VSS */ SA0_VDD /*!< SA0 connected to VDD */ }; MMA845x(I2C &i2c, MMA845x_SA0 const i2c_addr);
This is the error it gives me: No instance of constructor "MMA845x::MMA845x" matches the argument list
Notice that when I edit the library to have only the i2c definition without the i2c address, it doesn't give me that error so I know the problem is with the address part.
This is the whole library code: https://os.mbed.com/users/sam_grove/code/MMA845x/