Linux kernel module(3)
This post will give a simple introduction to Linux kernel module(Part III.).
Linux kernel module简介(三)
In this post we will discuss how to call kernel driver in user space.
Access IIO devices from user space
In last two posts we use a IIO(Linux Industrial I/O Subsystem) device st_uvis25 as a example to show how to write a kernel module. There are a lot of devices fall into this subsystem:
- ADCs
- Accelerometers
- Gyros
- IMUs
- Capacitance to Digital Converters (CDCs)
- Pressure Sensors
- Color, Light and Proximity Sensors
- Temperature Sensors
- Magnetometers
- DACs
- DDS (Direct Digital Synthesis)
- PLLs (Phase Locked Loops)
- Variable/Programmable Gain Amplifiers (VGA, PGA)
In st_uvis25_core.c, a iio_info has been defined and assigned to a iio_dev in probe function:
1 | // st_uvis25_core.c, Line 267 |
If devm_iio_device_register success and iio_info.read_raw has been registered, a file will be created at :
/sys/bus/iio/devices/iio:device0/xxx_raw
In terminal, you can read it by cat
1 | cat /sys/bus/iio/devices/iio:device0/xxx_raw |
In C/C++ applications, you can use fopen because it’s a file.