Acceleration sensor (CM-i.MX27)

From BlueWiki

Jump to: navigation, search

The DEV-i.MX27/35 contains a Three Axis Low-g Digital Output Accelerometer (MMA7455L). A rudimentary device driver for Linux is available.

1 Linux kernel configuration

Device Drivers  --->
  <*> Hardware Monitoring support  --->
    <*>   MMA7450 device driver

2 Linux test

  • Boot Linux. You should see the following files in the kernel log:
root@btmxc27:~# dmesg|grep mma7
mma7450: i2c-bus: MXC I2C Adapter; address: 0x1d
mma745x: before i2c_attach_client 0, adapter = c7cc2e00, address = 1d
input: mma7450 as /class/input/input1
mma7450 0-001d: mma7450 device is probed successfully.
root@btmxc27:~# 
  • You can view the chip's registers by reading the file /sys/class/hwmon/hwmon0/device/mma7450_ctl
  • Put the chip into measurement mode:
echo "setmod 1" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
  • Then read the X, Y, and Z registers (0x0-0x5) periodically with this little script:
#!/bin/sh
while true
do
clear
echo "readreg 1" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
echo "readreg 0" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
echo "readreg 3" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
echo "readreg 2" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
echo "readreg 5" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
echo "readreg 4" > /sys/class/hwmon/hwmon0/device/mma7450_ctl
sleep 0.1
done
  • Take your DEV board and rotate it, you will see the corresponding numbers change.
Personal tools