Day 26 - Sensor Core Refactor¶
๐ Date¶
2026-04-XX
๐ฏ Goal¶
Refactor I2C sensor driver into:
- Core + Bus architecture
- Transport-independent design
๐ง What I Did¶
- Introduced
mysensor_bus_ops - Abstracted hardware access
- Created
mysensor_core.c - Created
mysensor_i2c.c - Updated Makefile to multi-object module
๐งช Test Result¶
Driver probe¶
Stress Test Summary¶
IRQ mode¶
- irq_event_count = stable
- no skips
Polling mode¶
- poll_event_count matches expected
- periodic update working
Hybrid mode¶
- both IRQ and poll active
- skip logic observed
Cooldown test¶
- poll_skip_count increases significantly
- confirms cooldown works
๐ง What I Learned¶
- Separation of core vs transport is critical
bus_opsenables clean abstraction- IRQ + Polling interaction needs careful policy design
- Cooldown is essential to avoid excessive updates
โ ๏ธ Issues Encountered¶
container_oftype mismatch- header / struct inconsistency
- register naming inconsistency
โ Fixes¶
- unified
struct mysensor_core - corrected container_of usage
- standardized register naming
๐ Next Step¶
- Add SPI support (
mysensor_spi.c) - Verify core reusability