Is there any documentation in interfacing with the MMA 8452Q Linux Driver?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there any documentation in interfacing with the MMA 8452Q Linux Driver?

Jump to solution
1,426 Views
aliismail
Contributor IV

I have an MMA 8452Q accelerometer connected to an iMX6 SoM. I have successfully brought up the 8452 Linux driver and able to interface with it via sysfs. My question is, is there any documentation describing how to configure and set triggers for the MMA 8452 via sysfs?

EDIT: After spending some time and digging into iio devices, my original question is not exactly my issue. The mma8452 accel is currently set as the trigger. I have configured the 8452 accel to trigger an interrupt when motion is detected. I can successfully cause the 8452 accel to trigger. I have also successfully observed the mma8452 Linux driver capture the trigger. Based on what I have seen in the driver code, it executes an iio_push_event(). My question is, how do I observer this iio_push_event from userspace?

0 Kudos
1 Solution
1,173 Views
jamesbone
NXP TechSupport
NXP TechSupport

Hello  Ali,

i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC);   

It is the only function that you can use in UserSpace, with the I2Ctools Utility that can be access as command in UserSpace.  So instead of reading the values of the Accelerometer with the 

iio_push_event(indio_dev,                      IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X,                                IIO_EV_TYPE_MAG,                                IIO_EV_DIR_RISING),                      ts);

Just make the

i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC);   


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
4 Replies
1,173 Views
reyes
NXP TechSupport
NXP TechSupport

Please find attached a User Guide that describes how to configure and set triggers for the MMA8452 and other NXP sensors via sysfs.

1,173 Views
aliismail
Contributor IV

Hi Jose,

After spending some time and digging into iio devices, my original question is not exactly my issue. The mma8452 accel is currently set as the trigger. I have configured the 8452 accel to trigger an interrupt when motion is detect. I can successfully cause the 8452 accel to trigger. I have also successfully observed the mma8452 Linux driver capture the trigger. Based on what I have seen in the driver code, it executes an iio_push_event(). My question is, how do I observer this iio_push_event from userspace?

Thanks for the help!

0 Kudos
1,174 Views
jamesbone
NXP TechSupport
NXP TechSupport

Hello  Ali,

i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC);   

It is the only function that you can use in UserSpace, with the I2Ctools Utility that can be access as command in UserSpace.  So instead of reading the values of the Accelerometer with the 

iio_push_event(indio_dev,                      IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X,                                IIO_EV_TYPE_MAG,                                IIO_EV_DIR_RISING),                      ts);

Just make the

i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC);   


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,173 Views
aliismail
Contributor IV

Thanks for the reply James. This seems like my best bet. I was going to have to poll any event that was pushed to userspace anyways so your solution makes a lot of sense to me. I am still a little hazy on how the iio driver is supposed to be used, but I have what I need to detect motion.

Thanks for all your help!

Ali

0 Kudos