Steps:
(1) first, mem3280 is an I2C device, so the first step is to check the chip spec and determine its I2C address (0x30)
(2) After the address is determined, add I2C device information in the kernel/ARCH/ARM/mach-vc0882/board-vortex.c file:
1212 static struct i2c_board_info i2c_devs1 [] = {
1213 # ifdef config_sensor_ssz0304
1214 {i2c_board_info ("ssz0304-sensor", 0x55 ),},
1215 # endif
1216 # ifdef config_sensor_mmc3280
1217 {i2c_board_info ("mmc3280-sensor", 0x30 ),},
1218 # endif
..............................................................................
(3) The debug driver enables I2C communication, that is, data can be read. (See other I2C devices for the driver framework)
(4) After I2C is called, prepare to modify the Hal layer of Android. It is found that Hal processes sensors on the input device.
(5) change the driver to an input device (previously handled by a simple MISC device). You only need to refer to other input devices for this process.
(6) Now we have to deal with the Hal layer. We found that we didn't have to deal with the compass at all, and we had to add everything ourselves. This Hal is both awkward and complicated.
(7) There is no way to repeat all Hal's sensors processing functions and grasp the entire logic.
Note: Two test programs are used: hardware \ libhardware \ tests \ nusensors. cpp.
Frameworks \ base \ Services \ sensorservice \ tests \ sensorservicetest. cpp
An important debugging experience is to analyze functions and use loge printf to print debugging information. In addition, be careful and patient.