Interfacing to the Raspberry Pi Input/Outputs
Derek Molloy · 2016
This chapter introduces interfacing to general-purpose input/outputs (GPIOs) on the RPi platform using sysfs, memory-mapped registers, and the wiringPi library. Interfacing to GPIOs is an important topic, because understanding the key concepts facilitates the development of custom electronics circuits that can be interfaced and controlled from within embedded Linux. The use of internal pull-up/pull-down resistors and external optocouplers ensure that circuits can be safely connected to the RPi. The general concepts of Linux sysfs and memory-mapped GPIO register control are followed by a discussion on the wiringPi library, which utilizes these concepts. The wiringPi library is used to build GPIO input/output circuits, one-wire communications circuits, and pulse-width modulation (PWM) applications. The chapter finishes with a brief discussion on Linux access permissions. By the end of this chapter, the reader should be able to safely interface GPIO circuits to the RPi.