Hardware Reference
In-Depth Information
I²C Bus
As the name suggests, the Inter-Integrated Circuit (I²C) bus is designed to provide communica-
tions between multiple integrated circuits (ICs) . In the case of the Pi, one of those integrated
circuits is the Broadcom BCM2835 SoC processor at the heart of the system. hese pins include
access to pull-up resistors located on the Pi, meaning no external resistors are required to access
the I²C functionality.
he I²C bus can be accessed on Pins 3 and 5, with Pin 3 providing the Serial Data Line (SDA)
signal and Pin 5 providing the Serial Clock (SCL) signal. he I²C bus available on these pins is
actually only one of two provided by the BCM2835 chip itself, and is known as I²C0. he
second, I²C1, is terminated at resistors on the Raspberry Pi circuit board itself and is not
available for general-purpose use.
SPI Bus
he Serial Peripheral Interface (SPI) bus is a synchronous serial bus designed primarily for
in-system programming (ISP) of microcontrollers and other devices. Unlike the UART and I²C
buses, it's a four-wire bus with multiple Chip Select lines which allow it to communicate with
more than one target device.
he Pi's SPI bus is available on Pins 19, 21 and 23, with a pair of Chip Select lines on Pin 24
and Pin 26. Pin 19 provides the SPI Master Output, Slave Input (MOSI) signal; Pin 21 provides
the SPI Master Input, Slave Output (MISO) signal; Pin 23 provides the Serial Clock (SLCK) used
to synchronise communication; and Pins 24 and 26 provide the Chip Select signals for up to
two independent slave devices.
Although additional buses are present in the Raspberry Pi's BCM2835 SoC processor, they
are not brought out to the GPIO port and are thus unavailable for use.
Using the GPIO Port in Python
With the theory out of the way, it's time to get practical. In this section, you'll learn how to
install a library to allow easy access to the general-purpose pins on the Raspberry Pi's GPIO
port in Python. You'll also be shown two simple electronic circuits which demonstrate how
to use the GPIO port for input and output.
As you saw in Chapter 11, “Python Basics”, Python is a friendly yet powerful programming
language. It's not, however, the perfect choice for every scenario. Although it works ine for
the simple circuits you'll be creating in this chapter, it does not ofer what is known as deter-
ministic real-time operation. For the majority of users, this doesn't matter; if you're planning
on using the Pi at the heart of a nuclear reactor or a complex robotics platform, however, you
Search WWH ::




Custom Search