General Purpose Input-Output (GPIO) is the simplest way of connecting peripheral devices to the CPU. Every processor usually has some number of pins reserved for general purposes. These pins can be electrically connected directly to the pins of a peripheral device. An embedded application can control the device by changing the signal level of the pins configured for output or by reading the signal level of the input pins.
The interpretation of the signal levels does not follow any protocol and is determined by the peripheral device. Developers need to consult the device datasheet to be able to program the communication properly. Â
This type of communication is usually done on the kernel side using a dedicated device driver. This is, however, not always a requirement. In this recipe, we will learn how to...