GPIO access
This section presents the Circle classes, which implement digital input/output operations, using the pins exposed on the 40-pin GPIO (General Purpose Input/Output) header of the Raspberry Pi (26-pin on older models). This covers writing and reading a single or all exposed GPIO pin(s), providing GPIO clocks for different purposes (e.g. for Pulse Width Modulation (PWM) output), triggering interrupts from GPIO pins, using I2C and SPI interfaces, and switching the (green) Act LED.
Please see these documents for a description of the GPIO hardware:
BCM2835 ARM Peripherals (for Raspberry Pi 1 and Zero)
BCM2711 ARM Peripherals (for Raspberry Pi 4)
The first document is also valid for the Raspberry Pi 2, 3 and Zero 2 with some modifications (e.g. I/O base address).
Important
The Circle documentation (including all READMEs) uses SoC (BCM) numbers (0-53), when referring to specific GPIO pins. These numbers are different from the physical pin position numbers (1-40) on the GPIO header. Please see pinout.xyz for the mapping of SoC numbers to the header position.
CGPIOPin
This class encapsulates a GPIO pin, which can be read, write or inverted. A GPIO pin can trigger an interrupt, when a specific GPIO event occurs.
#include <circle/gpiopin.h>
-
class CGPIOPin
-
GPIO_PINS
Number of available GPIO pins (54).
Initialization
-
CGPIOPin::CGPIOPin(void)
Default constructor. Object must be initialized afterwards using
AssignPin()
,SetMode()
and optionallySetPullMode()
.
-
CGPIOPin::CGPIOPin(unsigned nPin, TGPIOMode Mode, CGPIOManager *pManager = 0)
Creates and initializes a
CGPIOPin
instance for GPIO pin numbernPin
, set pin modeMode
.pManager
must be specified only, if this pin will trigger interrupts (IRQ).nPin
can have a numeric value (0-53) or these special values:GPIOPinAudioLeft (GPIO pin, which gates the left PWM audio channel)
GPIOPinAudioRight (GPIO pin, which gates the right PWM audio channel)
Mode
can have these values:GPIOModeInput
GPIOModeOutput
GPIOModeInputPullUp
GPIOModeInputPullDown
GPIOModeAlternateFunction0
GPIOModeAlternateFunction1
GPIOModeAlternateFunction2
GPIOModeAlternateFunction3
GPIOModeAlternateFunction4
GPIOModeAlternateFunction5
-
void CGPIOPin::AssignPin(unsigned nPin)
Assigns a GPIO pin number to the object. To be used together with the default constructor and
SetMode()
. SeeCGPIOPin::CGPIOPin()
for the possible values fornPin
.
-
void CGPIOPin::SetMode(TGPIOMode Mode, boolean bInitPin = TRUE)
Sets GPIO pin to
Mode
. SeeCGPIOPin::CGPIOPin()
for the possible values. IfbInitPin
isTRUE
, this method initializes the pull-up/down mode and output level (LOW) too. To be used together with the default constructor andAssignPin()
or for dynamic changes of the direction for input/output pins.
Input / Output
-
void CGPIOPin::Write(unsigned nValue)
Sets the GPIO pin to
nValue
(output), which can beLOW
(0) orHIGH
(1).
-
unsigned CGPIOPin::Read(void) const
Returns the value, read from the GPIO pin (input). Can be
LOW
(0) orHIGH
(1).
-
static void CGPIOPin::WriteAll(u32 nValue, u32 nMask)
Sets the GPIO pins 0-31 at once.
nValue
specifies the levels of GPIO pins 0-31 in the respective bits to be written, wherenMask
is a bit mask for the written value. Only those GPIO pins are affected, for which the respective bit is set innMask
. The other pins are not touched.
Interrupts
A GPIO pin can trigger an interrupt (IRQ) under certain conditions. The CGPIOPin
object must be initialized with a pointer to an instance of the class CGPIOManager
for this purpose. There is maximal one instance of CGPIOManager
in the system.
-
void CGPIOPin::ConnectInterrupt(TGPIOInterruptHandler *pHandler, void *pParam, boolean bAutoAck = TRUE)
Connects the interrupt handler function
pHandler
to the GPIO pin, to be called on a GPIO event.pParam
is a user parameter, which will be handed over to the interrupt handler. IfbAutoAck
is TRUE, the GPIO event detect status will be automatically acknowledged, when the interrupt occurs. Otherwise, the interrupt handler must callAcknowledgeInterrupt()
. The GPIO interrupt handler has the following prototype:
void TGPIOInterruptHandler (void *pParam);
-
void CGPIOPin::DisconnectInterrupt(void)
Disconnects the interrupt handler from the GPIO pin. The interrupt source(s) must be disabled before using
DisableInterrupt()
andDisableInterrupt2()
, if they were enabled before.
-
void CGPIOPin::EnableInterrupt(TGPIOInterrupt Interrupt)
Enables a specific event condition to trigger an interrupt for this GPIO pin.
Interrupt
can be:GPIOInterruptOnRisingEdge
GPIOInterruptOnFallingEdge
GPIOInterruptOnHighLevel
GPIOInterruptOnLowLevel
GPIOInterruptOnAsyncRisingEdge
GPIOInterruptOnAsyncFallingEdge
-
void CGPIOPin::DisableInterrupt(void)
Disables a previously enabled event condition from triggering an interrupt.
-
void CGPIOPin::EnableInterrupt2(TGPIOInterrupt Interrupt)
Same function as
EnableInterrupt()
for a second interrupt source.
CGPIOPinFIQ
This class encapsulates a special GPIO pin, which is using the FIQ (Fast Interrupt Request) to handle GPIO interrupts with low latency. There is only one GPIO pin of this type allowed in the system.
#include <circle/gpiopinfiq.h>
CGPIOPinFIQ
is derived from CGPIOPin
and inherits its methods. For initialization it provides this special constructor:
-
CGPIOPinFIQ::CGPIOPinFIQ(unsigned nPin, TGPIOMode Mode, CInterruptSystem *pInterrupt)
The parameters are the same as for
CGPIOPin::CGPIOPin()
, with one exception:pInterrupt
is a pointer the single interrupt system object in the system. ACGPIOPinFIQ
object does not need an instance ofCGPIOManager
to generate interrupts.
CGPIOManager
This class implements an interrupt multiplexer for CGPIOPin
instances. There must be exactly one instance of CGPIOManager
in the system, if at least one GPIO pin triggers interrupts using the IRQ.
#include <circle/gpiomanager.h>
-
class CGPIOManager
-
CGPIOManager::CGPIOManager(CInterruptSystem *pInterrupt)
Creates a
CGPIOManager
instance.pInterrupt
is a pointer to the interrupt system object.
-
boolean CGPIOManager::Initialize(void)
Initializes the
CGPIOManager
object. Usually called fromCKernel::Initialize()
. ReturnsTRUE
, if the initialization was successful.
CGPIOClock
A GPIO clock is a programmable digital clock generator. A Raspberry Pi computer provides several of these clocks. Their output is used for special system purposes (e.g. for the PWM and PCM / I2S devices) or can be directly connected to some GPIO pins. GPIO clocks are driven by an internal clock source with a specific clock frequency.
#include <circle/gpioclock.h>
-
class CGPIOClock
-
CGPIOClock::CGPIOClock(TGPIOClock Clock, TGPIOClockSource Source = GPIOClockSourceUnknown)
Creates a
CGPIOClock
instance for GPIO clockClock
with clock sourceSource
.Clock
can be:Clock
Connected to
GPIOClock0
GPIO4 (ALT0) or GPIO20 (ALT5)
GPIOClock1
GPIO5 (ALT0) or GPIO21 (ALT5), Raspberry Pi 4 only
GPIOClock2
GPIO6 (ALT0)
GPIOClockPCM
PCM / I2S device
GPIOClockPWM
PWM device
The respective GPIO pin has to be set to the given
GPIOModeAlternateFunctionN
(ALTn), using aCGPIOPin
object, so that the signal can be accessed at the GPIO header.Source
can be:Source
Raspberry Pi 1-3
Raspberry Pi 4
GPIOClockSourceOscillator
19.2 MHz
54 MHz
GPIOClockSourcePLLC
1000 MHz (varies)
1000 MHz (may vary)
GPIOClockSourcePLLD
500 MHz
750 MHz
GPIOClockSourceHDMI
216 MHz
unused
If
Source
is set toGPIOClockSourceUnknown
, the clock source is selected automatically, whenStartRate()
is called.
-
void CGPIOClock::Start(unsigned nDivI, unsigned nDivF = 0, unsigned nMASH = 0)
Starts the clock using the given integer divider
nDivI
(1-4095). The MASH modes withnDivF > 0
are described in the BCM2835 ARM Peripherals document.
-
boolean CGPIOClock::StartRate(unsigned nRateHZ)
Starts the clock with the given target frequency
nRateHZ
in Hertz. Assigns the clock source automatically. ReturnsFALSE
, if the requested rate cannot be generated.
-
void CGPIOClock::Stop(void)
Stops the clock.
CPWMOutput
This class provides access to the Pulse Width Modulator (PWM) device, which can be used to generate (pseudo) analog signals on the GPIO pins 18 and 19 (two channels). These pins have to be set to GPIOModeAlternateFunction5
using the class CGPIOPin
for that purpose.
#include <circle/pwmoutput.h>
-
class CPWMOutput
-
CPWMOutput::CPWMOutput(TGPIOClockSource Source, unsigned nDivider, unsigned nRange, boolean bMSMode)
Creates a
CPWMOutput
object with clock sourceSource
and the dividernDivider
(equivalent tonDivI
, 1-4095). SeeCGPIOClock
for these parameters. For the parametersnRange
(Range) andbMSMode
(M/S mode) see the BCM2835 ARM Peripherals document.
-
void CPWMOutput::Start(void)
Starts the PWM clock and device.
-
void CPWMOutput::Stop(void)
Stops the PWM clock and device.
-
void CPWMOutput::Write(unsigned nChannel, unsigned nValue)
Write
nValue
(0-Range) to PWM channelnChannel
(1 or 2).
-
PWM_CHANNEL1
-
PWM_CHANNEL2
Macros to be used for the
nChannel
parameter.
CI2CMaster
This class is a driver for the I2C master devices of the Raspberry Pi computer. The GPIO pin mapping for the I2C master devices is as follows:
nDevice |
nConfig 0 (SDA SCL) |
nConfig 1 (SDA SCL) |
nConfig 2 (SDA SCL) |
Raspberry Pi boards |
---|---|---|---|---|
0 |
GPIO0 GPIO1 |
GPIO28 GPIO29 |
GPIO44 GPIO45 |
Rev. 1, other |
1 |
GPIO2 GPIO3 |
All other |
||
2 |
None |
|||
3 |
GPIO2 GPIO3 |
GPIO4 GPIO5 |
GPIO4 GPIO5 |
Raspberry Pi 4 only |
4 |
GPIO6 GPIO7 |
GPIO8 GPIO9 |
GPIO8 GPIO9 |
Raspberry Pi 4 only |
5 |
GPIO10 GPIO11 |
GPIO12 GPIO13 |
GPIO12 GPIO13 |
Raspberry Pi 4 only |
6 |
GPIO22 GPIO23 |
Raspberry Pi 4 only |
The Read()
and Write()
methods (see below) may return the following error codes as a negative value:
Value |
Description |
---|---|
I2C_MASTER_INALID_PARM |
Invalid parameter |
I2C_MASTER_ERROR_NACK |
Received a NACK |
I2C_MASTER_ERROR_CLKT |
Received clock stretch timeout |
I2C_MASTER_DATA_LEFT |
Not all data has been sent / received |
#include <circle/i2cmaster.h>
-
class CI2CMaster
-
CI2CMaster::CI2CMaster(unsigned nDevice, boolean bFastMode = FALSE, unsigned nConfig = 0)
Creates a
CI2CMaster
object for I2C masternDevice
(0-6), with configurationnConfig
(0 or 1). See the mapping above for these parameters. The default I2C clock is 100 KHz or 400 KHz, ifbFastMode
isTRUE
. This can be modified withSetClock()
for a specific transfer.
-
boolean CI2CMaster::Initialize(void)
Initializes the
CI2CMaster
object. Usually called fromCKernel::Initialize()
. ReturnsTRUE
, if the initialization was successful.
-
void CI2CMaster::SetClock(unsigned nClockSpeed)
Modifies the default clock before a specific transfer.
nClockSpeed
is the wanted I2C clock frequency in Hertz.
-
int CI2CMaster::Read(u8 ucAddress, void *pBuffer, unsigned nCount)
Reads
nCount
bytes from the I2C slave device with addressucAddress
intopBuffer
. Returns the number of read bytes or < 0 on failure. See the error codes above.
-
int CI2CMaster::Write(u8 ucAddress, const void *pBuffer, unsigned nCount)
Writes
nCount
bytes to the I2C slave device with addressucAddress
frompBuffer
. Returns the number of written bytes or < 0 on failure. See the error codes above.
CI2CSlave
This class is a driver for the I2C slave device. The GPIO pin mapping is as follows:
Raspberry Pi |
SDA |
SCL |
---|---|---|
1-3, Zero |
GPIO18 |
GPIO19 |
4 |
GPIO10 |
GPIO11 |
#include <circle/i2cslave.h>
-
class CI2CSlave
-
CI2CSlave::CI2CSlave(u8 ucAddress)
Creates the
CI2CSlave
object and assigns the I2C addressucAddress
.
-
boolean CI2CSlave::Initialize(void)
Initializes the
CI2CSlave
object. Usually called fromCKernel::Initialize()
. ReturnsTRUE
, if the initialization was successful.
CSPIMaster
The class CSPIMaster
is a driver for SPI master devices, with these features:
SPI non-AUX devices only
Standard mode (3-wire) only
Chip select lines (CE0, CE1) are active low
Polled operation only
The GPIO pin mapping is as follows:
nDevice |
MISO |
MOSI |
SCLK |
CE0 |
CE1 |
Support |
---|---|---|---|---|---|---|
0 |
GPIO9 |
GPIO10 |
GPIO11 |
GPIO8 |
GPIO7 |
All boards |
1 |
class CSPIMasterAUX |
|||||
2 |
None |
|||||
3 |
GPIO1 |
GPIO2 |
GPIO3 |
GPIO0 |
GPIO24 |
Raspberry Pi 4 only |
4 |
GPIO5 |
GPIO6 |
GPIO7 |
GPIO4 |
GPIO25 |
Raspberry Pi 4 only |
5 |
GPIO13 |
GPIO14 |
GPIO15 |
GPIO12 |
GPIO26 |
Raspberry Pi 4 only |
6 |
GPIO19 |
GPIO20 |
GPIO21 |
GPIO18 |
GPIO27 |
Raspberry Pi 4 only |
GPIO0 and GPIO1 are normally reserved for the ID EEPROM of hat boards.
#include <circle/spimaster.h>
-
class CSPIMaster
-
CSPIMaster::CSPIMaster(unsigned nClockSpeed = 500000, unsigned CPOL = 0, unsigned CPHA = 0, unsigned nDevice = 0)
Creates an
CSPIMaster
instance for access to SPI masternDevice
(see table above), with default SPI clock frequencynClockSpeed
in Hertz, clock polarityCPOL
(0 or 1) and clock phaseCPHA
(0 or 1).
-
boolean CSPIMaster::Initialize(void)
Initializes the SPI master. Usually called from
CKernel::Initialize()
. ReturnsTRUE
, if initialization was successful.
-
void CSPIMaster::SetClock(unsigned nClockSpeed)
Modifies the default SPI clock frequency before a specific transfer.
nClockSpeed
is the SPI clock frequency in Hertz. This method is not protected by an internal spin lock for multi-core operation.
-
void CSPIMaster::SetMode(unsigned CPOL, unsigned CPHA)
Modifies the default clock polarity / phase before a specific transfer.
CPOL
is the clock polarity (0 or 1) andCPHA
is the clock phase (0 or 1). These parameters must match the SPI slave settings. This method is not protected by an internal spin lock for multi-core operation.
-
void CSPIMaster::SetCSHoldTime(unsigned nMicroSeconds)
Sets the additional time, CE# stays active after the transfer. The set value is valid for the next transfer only. Normally CE# goes inactive very soon after the transfer, this sets the additional time, CE# stays active.
-
int CSPIMaster::Read(unsigned nChipSelect, void *pBuffer, unsigned nCount)
Reads
nCount
bytes intopBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 orChipSelectNone
). Returns the number of read bytes or < 0 on failure.
-
int CSPIMaster::Write(unsigned nChipSelect, const void *pBuffer, unsigned nCount)
Writes
nCount
bytes frompBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 orChipSelectNone
). Returns the number of written bytes or < 0 on failure.
-
int CSPIMaster::WriteRead(unsigned nChipSelect, const void *pWriteBuffer, void *pReadBuffer, unsigned nCount)
Simultaneous writes and reads
nCount
bytes frompWriteBuffer
and topReadBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 orChipSelectNone
). Returns the number of transferred bytes or < 0 on failure.
CSPIMasterAUX
The class CSPIMasterAUX
is a polling driver for the auxiliary SPI master (SPI1). The GPIO pin mapping is as follows:
MISO |
MOSI |
SCLK |
CE0 |
CE1 |
CE2 |
---|---|---|---|---|---|
GPIO19 |
GPIO20 |
GPIO21 |
GPIO18 |
GPIO17 |
GPIO16 |
The CE# signals are active low.
#include <circle/spimasteraux.h>
-
class CSPIMasterAUX
-
CSPIMasterAUX::CSPIMasterAUX(unsigned nClockSpeed = 500000)
Creates a
CSPIMasterAUX
object. Sets the default SPI clock frequency tonClockSpeed
in Hertz.
-
boolean CSPIMasterAUX::Initialize(void)
Initializes the SPI1 AUX master. Usually called from
CKernel::Initialize()
. ReturnsTRUE
, if initialization was successful.
-
void CSPIMasterAUX::SetClock(unsigned nClockSpeed)
Modifies the default SPI clock frequency before a specific transfer.
nClockSpeed
is the SPI clock frequency in Hertz. This method is not protected by an internal spin lock for multi-core operation.
-
int CSPIMasterAUX::Read(unsigned nChipSelect, void *pBuffer, unsigned nCount)
Reads
nCount
bytes intopBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 or 2). Returns the number of read bytes or < 0 on failure.
-
int CSPIMasterAUX::Write(unsigned nChipSelect, const void *pBuffer, unsigned nCount)
Writes
nCount
bytes frompBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 or 2). Returns the number of written bytes or < 0 on failure.
-
int CSPIMasterAUX::WriteRead(unsigned nChipSelect, const void *pWriteBuffer, void *pReadBuffer, unsigned nCount)
Simultaneous writes and reads
nCount
bytes frompWriteBuffer
and topReadBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 or 2). Returns the number of transferred bytes or < 0 on failure.
CSPIMasterDMA
The class CSPIMasterDMA
is a driver for the SPI0 master device. It implements an asynchronous DMA operation. Optionally one can do synchronous polling transfers (e.g. for small amounts of data). The GPIO pin mapping of the SPI0 master device is as follows:
MISO |
MOSI |
SCLK |
CE0 |
CE1 |
---|---|---|---|---|
GPIO9 |
GPIO10 |
GPIO11 |
GPIO8 |
GPIO7 |
#include <circle/spimasterdma.h>
-
class CSPIMasterDMA
-
CSPIMasterDMA::CSPIMasterDMA(CInterruptSystem *pInterruptSystem, unsigned nClockSpeed = 500000, unsigned CPOL = 0, unsigned CPHA = 0, boolean bDMAChannelLite = TRUE)
Creates a
CSPIMasterDMA
object. Sets the default SPI clock frequency tonClockSpeed
in Hertz, the clock polarity toCPOL
(0 or 1) and the clock phase toCPHA
(0 or 1).pInterruptSystem
is a pointer to the interrupt system object. SetbDMAChannelLite
toFALSE
for very high speeds or transfer sizes >= 64K.
-
boolean CSPIMasterDMA::Initialize(void)
Initializes the SPI0 master. Usually called from
CKernel::Initialize()
. ReturnsTRUE
, if initialization was successful.
-
void CSPIMasterDMA::SetClock(unsigned nClockSpeed)
Modifies the default SPI clock frequency before a specific transfer.
nClockSpeed
is the SPI clock frequency in Hertz.
-
void CSPIMasterDMA::SetMode(unsigned CPOL, unsigned CPHA)
Modifies the default clock polarity / phase before a specific transfer.
CPOL
is the clock polarity (0 or 1) andCPHA
is the clock phase (0 or 1). These parameters must match the SPI slave settings.
-
void CSPIMasterDMA::SetCompletionRoutine(TSPICompletionRoutine *pRoutine, void *pParam)
Sets a completion routine
pRoutine
to be called, when the next transfer completes.pParam
is a user parameter, which is handed over to the completion routine. The prototype of the completion routine looks like this:
void TSPICompletionRoutine (boolean bStatus, void *pParam);
bStatus
is TRUE
on success.
-
void CSPIMasterDMA::StartWriteRead(unsigned nChipSelect, const void *pWriteBuffer, void *pReadBuffer, unsigned nCount)
Starts a simultaneous write and read transfer of
nCount
bytes frompWriteBuffer
and topReadBuffer
. Chip selectnChipSelect
(CE#, 0, 1 orChipSelectNone
) will be activated during the transfer. The buffers must be aligned to the size of a data-cache-line (see DMA buffers).
-
int CSPIMasterDMA::WriteReadSync(unsigned nChipSelect, const void *pWriteBuffer, void *pReadBuffer, unsigned nCount)
Simultaneous writes and reads
nCount
bytes frompWriteBuffer
and topReadBuffer
. Activates chip selectnChipSelect
(CE#, 0, 1 orChipSelectNone
). Returns the number of transferred bytes or < 0 on failure. Synchronous (polled) operation for small amounts of data.
CSMIMaster
The class CSMIMaster
is a driver for the Secondary Memory Interface (SMI) device of the Raspberry Pi. It supports the following features:
Drives any combination of SMI data lines (GPIO8 to GPIO25)
May also drive SMI address lines (GPIO0 to GPIO5)
Does not use SOE / SWE lines on GPIO6 / GPIO7
Read / Write operation in direct mode, or Write-only in DMA mode
Note
One must first call CSMIMaster::SetupTiming()
with suitable timing information. The device bank to use and the address to assert on the SAx lines may then optionally be set with CSMIMaster::SetDeviceAndAddress()
. Then direct mode may be used with CSMIMaster::Read()
or CSMIMaster::Write()
, or for DMA mode one must first call CSMIMaster::SetupDMA()
with a suitable buffer, then CSMIMaster::WriteDMA()
to flush the buffer to SMI.
#include <circle/smimaster.h>
-
class CSMIMaster
-
CSMIMaster::CSMIMaster(unsigned nSDLinesMask = 0x3FFFF, boolean bUseAddressPins = TRUE)
Creates a
CSMIMaster
object. There can be only one.nSDLinesMask
is a bit mask, which determines which SDx lines should be driven. For example(1 << 0) | (1 << 5)
for SD0 (GPIO8) and SD5 (GPIO13).bUseAddressPins
enables the use of the address pins GPIO0 to GPIO5, if it is set toTRUE
.
-
unsigned CSMIMaster::GetSDLinesMask(void)
Returns the
nSDLinesMask
, handed over to the constructor.
-
void CSMIMaster::SetupTiming(TSMIDataWidth Width, unsigned nCycle_ns, unsigned nSetup, unsigned nStrobe, unsigned nHold, unsigned nPace, unsigned nDevice = 0)
Sets up the SMI cycle.
nWidth
is the length of the data bus (see below).nCycle_ns
is the clock period for the setup/strobe/hold cycle (in nanoseconds).nSetup
is the setup time, that is used to decode the address value (in units ofnCycle_ns
).nStrobe
is the width of the strobe pulse, that triggers the transfer (in units ofnCycle_ns
).nHold
is the hold time, that keeps the signals stable after the transfer (in units ofnCycle_ns
).nPace
is the pace time in between two cycles (in units ofnCycle_ns
).nDevice
is the settings bank to use (0 .. 3).
-
enum TSMIDataWidth
Values for specifying the width of the SMI data bus:
SMI8Bits
SMI9Bits
SMI16Bits
SMI18Bits
-
void CSMIMaster::SetupDMA(void *pDMABuffer, unsigned nLength)
Sets up DMA for (potentially multiple) SMI cycles of data from the buffer
pDMABuffer
(must be DMA-aligned).nLength
is the length of the buffer in bytes.
-
void CSMIMaster::SetDeviceAndAddress(unsigned nDevice, unsigned nAddr)
Defines the device and address to use for the next Read/Write operation.
nDevice
is the settings bank to use (0 .. 3).nAddr
is the value to be asserted on the address pins SAx.
-
unsigned CSMIMaster::Read(void)
Issues a single SMI read cycle from the SDx lines, and returns the read value.
-
void CSMIMaster::Write(unsigned nValue)
Issues a single SMI write cycle, i.e. writes the value
nValue
to the (enabled) SDx lines.
-
void CSMIMaster::WriteDMA(boolean bWaitForCompletion)
Triggers a DMA transfer of a few cycles with the buffer/length specified in
SetupDMA()
.bWaitForCompletion
specifies whether to wait for DMA completion before returning.
CActLED
This class switches the (green) Act(ivity) LED on or off. It automatically determines the Raspberry Pi model to use the right LED pin for the model.
#include <circle/actled.h>
-
class CActLED
-
CActLED::CActLED(boolean bSafeMode = FALSE)
Creates the
CActLED
object. Safe mode works with LEDs connected to GPIO expander and chain boot, but is not as quick.