This repo contains:
gpio-sysfs.c— simple sysfs-based GPIO control (learning / compatibility).gpio-libgpiod.c— modern libgpiod-based GPIO control.simulator.py— virtual sysfs GPIO simulator (no hardware needed).Makefile,test.sh,.gitignore, this README.
- Build:
make
- Run simulator & test:
./test.sh
- The sysfs program uses
/sys/class/gpioby default. For simulation setVIRT_GPIO_ROOTto simulator root. gpio-libgpiodrequires libgpiod development headers.- Use Git to track sources; recommended files to include shown below.
- All
.c,.h,Makefile,simulator.py,test.sh,README.md .gitignore(provided)
Flow Explanation:
1.GPIO Initialization:
Sets up GPIO pins, decides whether to use sysfs (older interface) or libgpiod (modern interface).
- Sysfs / libgpiod Control:
Sysfs: export pins, set direction (in/out), write 0/1.
libgpiod: open GPIO chip, request line, set value.
3.Simulation / Visualization:
simulator.py shows LEDs turning on/off virtually.
test.sh can automate toggling sequences.
4.Verification:
Observe console outputs, LED simulation, or test scripts to verify GPIO behavior.
Add an appropriate license file if needed (e.g. LICENSE).