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!!
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
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