October 2017
Intermediate to advanced
586 pages
14h 8m
English
Let's have a closer look at the digital triaxial acceleration sensor BMA220 from Bosch. This is an SPI/I2C-compatible device, with 8-bit-sized registers, along with an on-chip motion-triggered interrupt controller, which actually senses tilt, motion, and shock vibration. Its data sheet is available at http://www.mouser.fr/pdfdocs/BSTBMA220DS00308.PDF, and its driver has been introduced since kernel v4.8 (CONFIG_BMA200). Let's walk through it.
Firstly, we declare our IIO channels using struct iio_chan_spec. Once the triggered buffer is used, then we need to fill the .scan_index and .scan_type fields:
#define BMA220_DATA_SHIFT 2 #define BMA220_DEVICE_NAME "bma220" #define BMA220_SCALE_AVAILABLE "0.623 1.248 2.491 4.983" ...