Day 11 - GPIO Driver with IRQ¶
๐ฏ Goal¶
Extend GPIO driver to support:
- Multiple LEDs
- Button input
- Interrupt handling (IRQ)
๐ What I Did¶
1. Device Tree¶
Defined GPIO mapping:
Compiled overlay:
2. Driver Update¶
Added:
- led1 / led2 output
- button input
- IRQ handling
Key APIs:
3. ISR Implementation¶
Observed:
- IRQ triggers on both edges
- button bounce occurs
4. Debugging¶
Issue 1: IRQ compile error¶
Error:
Fix:
Issue 2: DTS compile error¶
Cause: - GPIO_ACTIVE_LOW not recognized
Fix:
Issue 3: Permission denied¶
Error:
Fix:
Issue 4: sudo redirect issue¶
5. Makefile Improvement¶
Added:
- module build
- overlay build
- deploy
- load/unload
๐งช Test Result¶
LED Control¶
โ OK
Read State¶
โ OK
IRQ¶
- IRQ triggered on button press
- Multiple triggers observed (bounce)
โ OK
๐ง Key Learnings¶
- Platform driver + Device Tree integration
- GPIO descriptor API (gpiod)
- Interrupt handling in kernel
- ISR design constraints
- Difference between polling vs interrupt
- Real-world issue: button bounce
โ ๏ธ Limitations¶
- No debounce handling
- Still polling in userspace
- IRQ logging not optimized
๐ Next Step¶
Day 12:
- wait queue
- blocking read
- poll / select support
Goal: ๐ Event-driven driver