Skip to content

boschmemssolutions/SMA13x-Sensor-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

SMA13x-Sensor-API and Sensor Driver

Table of Contents

Introduction

License

See LICENSE file

Sensor interfaces

  • I2C
  • SPI

Architecture

                  User space
-------------------------------------------------------
                 |          |
               sysfs       dev
                 \          /
               input-subsystem
	             |
sensor_API <-- sma13x_driver --> sma13x_SPI/I2C_driver
                                           |
                                      SPI/I2C_bus
                                           |
-------------------------------------------------------
                  Hardware

Operation examples

  1. Userspace The driver exposes a device file node under /dev/input/event*, which can be read as a normal Linux file. Tools like evtest can also be used for read data out. Eg.:
sudo evtest /dev/input/event0

The data will be displayed on the console with timestamp.

  1. Sysfs The driver also exposes a set of sysfs nodes under /sys/devices/virtual/input/input*, where users can get information about the sensor and also control the sensor. Eg.:

# read the chip id
cat /sys/devices/virtual/input/input0/chip_id

# read the asynced acc data 
cat /sys/devices/virtual/input/input0/value

# read the acc power config 
cat /sys/devices/virtual/input/input0/pw_cfg

# set the acc power to normal mode
echo 0 > /sys/devices/virtual/input/input0/pw_cfg

# set the acc power to suspend mode
echo 3 > /sys/devices/virtual/input/input0/pw_cfg