How to implement the MMA8452 Linux Kernel Driver?

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

How to implement the MMA8452 Linux Kernel Driver?

1,146 Views
DillonM
Contributor II

Hello,

I am working with an MMA8451Q accelerometer in an embedded Linux environment running kernel 4.19.94. The goal is to create a kernel module that will detect an interrupt from the accelerometer when the orientation changes, and then read the 0x10 register of the accelerometer to determine what the actual orientation is.

So far, I have configured the MMA8451Q to send an interrupt when the orientation changes using i2cset and i2cget commands from userspace, and have created a kernel module that successfully detects this interrupt.

My issue now is that I am in kernel space, so I can no longer use the simple i2cget command from the i2c-tools package in order to read the 0x10 register of the accelerometer. Instead, I have turned to the mma8452 kernel driver (which includes the MMA8451Q) in order to read the register without needing c libraries. Unfortunately, I cannot find any documentation or examples on how to use this driver. I have been able to successfully make and install the module into my kernel, as well as import the driver functions into my ISR kernel module, but cannot figure out how to implement said functions, or even what function I need.

So, I am asking if anyone is aware of any documentation regarding the MMA8452 driver.

Also, if there is another way to access the registers of the MMA8451Q through i2c without using c libraries (so it will function in a kernel module) that would work as well. Basically, creating my own driver to achieve one simple function: reading a register.

Any help would be much appreciated!!

Labels (1)
0 Kudos
Reply
3 Replies

1,137 Views
diazmarin09
NXP TechSupport
NXP TechSupport

Hello,

I hope all is great with you.

Unfortunately I am not aware of such driver. Please accept my apologies.

Have you considered using the drivers from the link below?

NXP Sensor Drivers for Android™, Linux® and other OS

Regards,

David

0 Kudos
Reply

1,131 Views
DillonM
Contributor II
I have not seen the driver mentioned, no. It does seem to replace the driver provided by the Linux Kernel however and should work. As someone who is new to using kernel drivers however, is there some example usage or further documentation I can view in order to get a better understanding of how to actually call the "mma8x5x_read_data" function for example?
0 Kudos
Reply

1,120 Views
diazmarin09
NXP TechSupport
NXP TechSupport

Hello,

I am afraid that we do not have any further documentation or example. As mentioned before, this device is obsolete. Please accept my apologies.

For further information about the I2C operation (single byte read for example), I do recommend reviewing the chapter 5.11.1 from the datasheet or using the example codes provided before as a reference.

 

I hope this information helps.

Regards,

David

0 Kudos
Reply