How to read data from i.mx53 QSB's mma8450 accelerometer?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read data from i.mx53 QSB's mma8450 accelerometer?

957 Views
Contributor II

Hi!

I need some help to read data from the accelerometer sensor included in i.Mx53 QSB.

I've installed the mma8450 device driver and during system boot I can see this messages:

 

check mma8450 chip ID
mma8450 0-001c: build time Jul  1 2011 08:22:07
input: mma8450 as /devices/virtual/input/input3
add mma8450 i2c driver

 

Now, how can I read data from each axis, and how can I set sensor configuration (eg.: change sensivity)?

 

Thanks in advance!

_____________________

Fernando Ginez da Silva

0 Kudos
2 Replies

24 Views
NXP Employee
NXP Employee

Try with something like this...

I am seeing weird results on Z axis though...

.....................................

#include <linux/input.h>
#include <errno.h>

int fd;
input_event event;

fd = open("/dev/input/event2", O_RDONLY | O_NDELAY);

if(fd == -1){
        printf("Unable to open /dev");
        return 0;
    }
    
    ssize_t ret;
        
    while(ret=read(fd, &event, sizeof(struct input_event)))
    {

    if (ret!=-1){
        if (event.type==EV_ABS){
            if (event.code=0)
                 printf("ax=%d\r",event.value);
           if (event.code=1)
                 printf("ay=%d\r",event.value);
           if (event.code=2)
                 printf("az=%d\r",event.value);
        }
        else{

            //then it is a SYNC
        }

................................. close the loop.........................

0 Kudos

24 Views
NXP Employee
NXP Employee
You can use evtest. Check it on package list (LTIB)
0 Kudos