This small set of files is a sort of "foundation", I use them for all my RPi projects that interface to the outside world. In no special order and not exhaustively:
- #Mons2015 LED Screen ElectroSuper
- #Discrete watchdog
- #SPI Flasher
- #Remote buttons over Ethernet cable
- #micro HTTP server in C
- #Electronics Workshops Resources
- #Simon Says learn Pi and IoT
This file is also used as a basis for my compact #C SPI library for Raspberry Pi (and others, later)
It's pretty well tested now, it was published in 2014 (https://boutique.ed-diamond.com/gnulinux-magazine-hors-series/789-gnulinux-magazine-hs-75.html) but the limits are understood as well.
I published it here so I have a stable repository for this cornerstone software, but also to motivate me to support the newer chips, and eventually port it to other architectures.
In 2014 I added the "parachutes" (atexit() calls) which is mostly OK for development but if you need real reliability, use the #Discrete watchdog system.
In 2017 I finally added support for RPi2 and RPi3.
Bonus: 2 dumb example programs and 3 tiny bash scripts that will save your @$$
Note: Direct access to the GPIO pins (as well as detection script) requires the program to run with root rights, or as setuid root. Compilation usually uses this kind of script:
sudo ./detect_GPIO_BASE.sh gcc $GPIO_BASE -Wall -o program program.c &&\ sudo chown root program &&\ sudo chmod +s program
I know there are new ways to use GPIOs without root (through /dev/gpiomem) but I'm so used to it that I don't bother, since I run hard real-time SW that need other root goodies...