From the version 4.8, the Linux kernel introduces a new user space API based on character devices for managing and controlling GPIOs ( General-Purpose Input/Output). This post presents the basic of the new interface as well as a simple tutorial/example to demonstrate how to use the new API to control GPIOs.
The hardware used in the tutorial is the Raspberry Pi 3B but the code is generic and can be used on any embedded hardware.
This is a migrated version of my Wordpress post, written on : 14 Mars 2015
The LPC1114FN28 has two pin ports (0 and 1) that make totally 22 pins (12 for port 0 and 10 for port 1, as shown in the image below). All of these pins could be used as GPIOs. By default, they are all input and pull up-enable (that is each pin is connected to an internal pull-up resistor) except for PIO0_5 (dp5) and PIO04 (dp27) which are "open-drain" (a transistor connects to low and nothing else). Their functionalities can be configured easily by software.
The figure below shows the pin out of the chip, note that each PIOn_m refers to the pin m on the port n.