The goal of my outreachy project is to write a driver for a sensor using the Industrial I/O interface. The sensor chosen is ADXL345 from Analog Devices. This sensor is a 3-axis digital accelerometer with high resolution measurement of +/-(2g/4g/8g and 16g).
This sensor is no stranger to me. I used this before on a school project. It’s amusing that I’m writing a driver for it now. Come to think of it, this sensor choice from that school project is overkill where we could’ve gone with a much simpler sensor for tilt determination.
Overview of features
The adxl345 is feature-filled:
- Measurement ranges of 2g, 4g, 8g and 16g as mentioned before
- Resolution: fixed 10-bit resolution or full resolution where resolution increases with range, up to 13-bit resolution at +/- 16g
- Sensing functions: activity/inactivity, single/double taps in any direction, free-fall detection
- Power modes: low power, auto sleep and standby mode
- 32-level FIFO buffer
- I2C and SPI (3-and 4-wire) digital interfaces
Planned Features for the Minimal Driver
As of this writing, I’m still waiting for the sensor to arrive. I have written device probing and support for read raw which I will write about on a separate post. I am told that these are enough for the initial support submission. Let’s see if I could include the scale as well.
I set up a development branch under my clone of the IIO tree, created the source file under accel/ and modified the Kconfig and Makefile so that I could build the driver in-tree without hiccups. Here’s what it looks like:
I just follow the kernel patch philosophy where you commit only one specific change at a time so that it’s easier to review. Here’s what my git log looks like so far with the first pre-patch being the Kconfig+Makefile modification.
Here are some sources I’ll be referring to during the writing process:
- Existing drivers in dirvers/iio/accel/
- Industrial I/O driver developer’s guide
Thanks for reading!