Hi
Here is some pseudocode for the initialization and sampling for the MMA8451Q
After initializing you should be able to read.
For the i2c_read and i2c_write, you can follow the implementation done for the mma7760 at <mqx_installation>/demo/accelerometer/accel_i2c.c
#define ADDR = 0x1C
typedef struct data {
char reg
char value
} data
Initialize_MMA8451Q {
data.reg = 0x11 //PL_CFG
data.val = 0xc0
i2c_write(12c0, ADDR, data, sizeof(data))
data_reg = 0x2a //CTRL_REG1
data.val = 0x01
i2c_write(12c0, ADDR, data, sizeof(data))
}
#define READ_DATA 0x01
#define READ_STATUS 0x10
sample_MMA8451Q {
char x,y,z, status;
char rcv_buf[6];
i2c_read(12c0, ADDR, READ_DATA, rcv_buf, sizeof(rcv_buf));
x = rcv_buf[0];
y = rcv_buf[2];
z = rcv_buf[4];
i2c_read(12c0, ADDR, READ_STATUS, rcv_buf, 3);
status = rcv_buf[0];
}
I will try to have get a sample version, probably by the end of next week.