Day 41 – Notes: IIO Control Plane v3¶
🧭 Overview¶
Day 41 focuses on completing a clean and extensible control plane across:
- STM32 firmware (register model v3)
- Linux IIO driver (
myadc_iio.c)
Key idea:
Separate what the sensor does from how it notifies events.
🧱 Control Plane Architecture (v3)¶
Components¶
ACQ_MODE¶
Defines how the sensor acquires data:
| Mode | Description |
|---|---|
| IDLE | No sampling |
| CONTINUOUS | Periodic sampling |
| FIFO | Buffered sampling |
| ONE_SHOT | Single sample on command |
IRQ_MASK¶
Selects which event generates an interrupt:
| Bit | Event |
|---|---|
| DATA_READY | New sample available |
| FIFO_WATERMARK | FIFO reached threshold |
| FIFO_FULL | FIFO full |
| ONE_SHOT_DONE | One-shot completed |
CMD¶
Explicit command interface:
🔄 v2 vs v3 Comparison¶
v2 (coupled design)¶
Problems:
- Mode + IRQ tightly coupled
- Hard to extend
- Driver must understand bit combinations
v3 (decoupled design)¶
Advantages:
- Clear separation of concerns
- Easier to extend
- Cleaner Linux driver mapping
🔗 Linux Driver Mapping¶
| Linux Interface | Register |
|---|---|
| mode | ACQ_MODE |
| one_shot | CMD |
| internal policy | IRQ_MASK |
⚙️ Driver Design Principles¶
1. Mode is passive¶
2. Command triggers action¶
3. IRQ policy is independent¶
4. Data path unchanged¶
- FIFO path untouched
- Buffer path untouched
Only control plane updated.
🧠 Key Concepts¶
One-shot is command-driven¶
Correct:
Incorrect:
Decoupling¶
Firmware:
- Fully decoupled
Linux:
- Currently uses mode-based default IRQ policy
- Can be extended later
Deterministic behavior¶
Every action must be explicit:
- Set mode
- Set IRQ mask
- Trigger acquisition
⚠️ Design Pitfalls¶
Mixing background task in register tests¶
Issue:
- FIFO test corrupted by timer-driven updates
Fix:
-
Separate:
-
register model tests
- task integration tests
Implicit side effects¶
Avoid:
- Mode causing sampling
- IRQ tied to mode implicitly
📌 Summary¶
Day 41 establishes:
- Clean control plane
- Explicit command-based design
- Proper separation between mode and IRQ
- Stable integration between firmware and Linux driver
🚀 Next Topics¶
- IRQ policy exposure to user space
- Blocking one-shot helper
- IIO trigger integration
- Driver refinement