Skip to content

Day33 Log - Minimal IIO Driver

Summary

Implemented a minimal IIO driver using a platform device.

Key features:

  • Single voltage channel
  • RAW and SCALE attributes
  • Direct mode (no buffer)

Issues Encountered

1. Unknown symbol error

Cause:

  • IIO core module not loaded

Solution:

sudo modprobe industrialio

2. No iio:deviceX created

Cause:

  • Platform driver had no matching device
  • probe() not executed

Solution:

  • Created dummy platform device inside module:
platform_device_register_simple("myiio_dummy", ...)

Observations

1. sysfs auto-generation

Attributes such as:

in_voltage0_raw
in_voltage0_scale

were automatically created by IIO core.


2. read_raw() mapping

Verified:

cat → IIO core → read_raw() → return value

3. Channel-driven interface

Changing iio_chan_spec directly affects:

  • sysfs attribute names
  • available features

4. Scale formatting

Using:

IIO_VAL_INT_PLUS_MICRO

produces:

0.001000

Key Learning

  • IIO uses metadata-driven design
  • Device model (probe) is essential
  • Framework handles user-space interface

Reflection

This minimal driver behaves like:

hwmon-like single-shot sensor

but provides a foundation for:

  • multi-channel sampling
  • buffered data
  • trigger-based acquisition