Skip to content

Day35 - IIO + DRDY GPIO + IRQ Integration

Overview

This day extends the IIO I2C driver by introducing data-ready (DRDY) interrupt signaling.

Key idea:

  • Move from polling (pull model) to interrupt-driven (push model)
  • Establish the pipeline:
Sensor → DRDY GPIO → Linux IRQ → driver handler

This prepares the system for IIO trigger/buffer mode (Day36).


System Architecture

STM32 (fake sensor)
 ├── sensor_reg (register model)
 ├── sensor_task (sample update)
 ├── sensor_gpio (DRDY pulse)
 └── i2c_slave (transport)

        ↓ I2C + GPIO

Linux
 ├── I2C driver
 ├── IRQ handler
 └── IIO framework (direct mode)

DRDY Signal Design

Design Choice

  • Active-low pulse
  • Triggered on new sample
  • Non-blocking, time-controlled
HIGH → LOW → HIGH

Implementation Flow

sensor_task_process()
generate sample
set DATA_READY
trigger DRDY pulse

GPIO Pulse Model

STM32 Side

  • DRDY asserted via GPIO
  • Pulse width controlled in sensor_gpio_process()
LOW (assert)
→ delay (pulse width)
→ HIGH (deassert)

Why Pulse Instead of Level?

Mode Problem
Level IRQ storm or no re-trigger
Pulse Clean edge trigger

Linux IRQ Integration

Device Tree

interrupt-parent = <&rp1_gpio>;
interrupts = <23 2>;   // GPIO23, falling edge

Driver Integration

probe()
get irq from client->irq
request_threaded_irq()

IRQ Handler

IRQ
→ threaded handler
→ log / debug

(Current stage: no data consumption yet)


Data Flow

STM32 sample update
DRDY pulse
Linux IRQ
driver handler
(user still reads via sysfs)

Comparison with Day34

Day34 Day35
polling read interrupt notification
CPU pulls data sensor pushes event
no IRQ GPIO interrupt

Key Concepts

1. Sensor must be explicitly configured

Driver must enable:

  • measurement engine
  • DRDY interrupt
CONFIG = ENABLE | DRDY_EN

2. IRQ is only a trigger, not data path

IRQ → notify
read_raw() → fetch data

3. Separation of concerns

Layer Responsibility
sensor_task generate data
sensor_gpio signal event
driver receive IRQ
IIO expose interface

Limitations (Current Stage)

  • No data consumption in IRQ
  • No buffer / trigger
  • DATA_READY not cleared by host
  • No timestamp

Next Step (Day36)

  • Introduce IIO trigger
  • Push data into buffer
  • Enable /dev/iio:deviceX
  • Add timestamped samples