In the previous chapter, we made use of the GPIO subsystem of the kernel to manage a LED, now we'll go further to manage the GPIOs from the kernel using a dedicated driver. Actually, what we are going to write is not properly a driver for a real device, but we can use it in order to show you how a complex kernel functionality can be abstracted as a file.
Let's suppose we need to count some pulses that arrive on our BeagleBone Black in a certain amount of time; in this case, we can use one GPIO for each pulse source. We can also consider that the maximum possible pulse frequency is really low (max 50 Hz).
Tip
Note that this situation is quite common, and it can be found in some counter devices. In fact, these devices simply count quantities (water or oil liters, energy power, and so on), and return the counting as frequency modulated pulses.
In this situation, we can use a really simple kernel code to implement a new devices class under the sysfs
filesystem that...