RPICSIO

The GpioConfig Class

 

The GpioConfig Class

The GpioConfig class provides a container to correlate various GPIO related information such as HeaderPinNumber, the GPIO and also the configuration state of the GPIO. This class is used for both the SYSFS and MemoryMapped versions of the RPICSIO classes and some class members are only relevant during a specific access mode.

This class is primarily intended for internal use within the various port objects and there is little need for direct interaction by external objects. These objects are usually auto-generated in the constructor of the port classes from the input GpioID using the tools and configuration information hardcoded in the static GpioUtils class.

 

Source Code

The source code for this class is available online for download and also in browseable form.

 

Syntax

public class GpioConfig

A class to contain all of the required data for a GPIO.

 

Public Constructors

public GpioConfig()

Default Constructor.

 

public GpioConfig(int headerPinIn, bool isDefaultGPIOOnHeaderIn, int gpioNumIn, GpioEnum gpioIn)

Constructor.

Parameters
headerPinIn - The number of the header pin.
isDefaultGPIOOnHeaderIn - true the GPIO is default on the header, false it is not.
gpioNumIn - The gpio as a number.
gpioIn - The gpio as an enum.

 

Public Methods

public string GpioSettingsAsString()

Outputs the GPIO Settings as a string.

 

Public Properties

public int EventBank { get; }

Gets the event bank number. This function just recovers the bank from the calculated GPIO number.

value
The event bank. This is the just GPIO/32.

 

public int EventBit { get; }

Gets the event bit number. This is the offset of a GPIO into its bank.

value
The event bit. This is the remainder of GPIO/32.

 

public GpioEnum Gpio { get; }

Gets the Gpio enum. There is no set accessor - this value set in the Constructor.

value
The Gpio as an enum.

 

public int GpioBank { get; }

Gets the Gpio bank. There is no set accessor - this value is calculated from the GpioID in the Constructor.

value
The Gpio bank which will be a value of 0 or 1.

 

public int GpioBankOffset { get; }

Gets the Gpio bank offset. There is no set accessor - this value is calculated from the GpioID in the Constructor.

value
The Gpio bank offset which will be a value of 0 or 4.

 

public int GpioBit { get; }

Gets the Gpio bit. There is no set accessor - this value is calculated from the GpioID in the Constructor.

value
The bit offset in the PinMux Gpio bank. This is the remainder of GpioNum/32.

 

public int GpioMask { get; }

Gets the Gpio mask. There is no set accessor - this value is calculated from the GpioID in the Constructor.

value
The bit offset in the PinMux Gpio bank. This is a 0x01 shifted left by the GpioBit value.

 

public GPIOPinMuxModeEnum GpioMode { get; }

Gets the mode of the GPIO - this is the setting of the pinmux. There is no set accessor - this value is calculated from the GpioID in the Constructor.

value
The pinmux mode state of the GPIO.

 

public int GpioNum { get; }

Gets the number of GPIO. There is no set accessor - this value is set in the Constructor.

value
The number the GPIO.

 

public int GpioPinMuxModeMask { get; }

Gets the mode mask for the GPIO. There is no set accessor - this value is calculated from the GpioNum.

value
The pinmux mode mask for the GPIO.

 

public int GpioPinMuxModeShift { get; }

Gets the number of bits we have to shift the function (pinmux) register to convert it to or from an int. There is no set accessor - this value is calculated from the GpioNum.

value
The pinmux mode mask shift value for the GPIO.

 

public int GpioSetting { get; }

Gets the GpioSettings. This is the raw hex bits that determine the various mode settings.

value
The bits of the Gpio Setting.

 

public int HeaderPin { get; }

Gets the Header Pin. There is no set accessor - this value set in the Constructor.

value
The header pin. This is the pin which exposes the GPIO on the header.

 

public bool IsDefaultGPIOOnHeader { get; }

Detects if the GPIO is a default GPIO on the header rather than needing to be muxed in because that pin is used by some other device. There is no set accessor - this value set in the Constructor.

value
true the GPIO is a default GPIO, false it is not.

 

public int MuxMode { get; }

Gets the Mux Mode. Gets the MuxMode. These are the three lsb bits of the GpioSetting.

value
The mux Mode. Essentially just gpioSetting & 0x07;

 

public string MuxOwner { get; }

Gets the Mux Owner. There is no set accessor - this value is set via a call to UpdateConfigurationWithPinmuxPinsFileInfo()

value
The mux owner. Only set on SYSFS mode ports

 

public int MuxPin { get; }

Gets the Mux Pin. There is no set accessor - this value is set via a call to UpdateConfigurationWithPinsFileInfo()

value
The mux pin. Only set on SYSFS mode ports

 

public int PinmuxRegisterOffset { get; }

Gets the PinMux register offset. There is no set accessor - this value set in the Constructor.

value
The PinMux register offset.

 

public string PinmuxRegisterOffsetAsHexString { get; }

Gets the PinMux register offset. There is no set accessor - this value calculated from the PinmuxRegisterOffset.

value
The PinMux register offset as a hex string. This is a convenience for display purposes.

 

public int PullupPulldownMode { get; }

Detects if the gpio is in pull up or pull down mode. There is no set accessor - this value calculated from the GpioSetting.

value
The PullupsPulldownsEnabled state. The actual pull up or pull down resistor is only truely operational if PullupsPulldownsEnabled is true.

 

public bool PullupsPulldownsEnabled { get; }

Detects if pullups/pulldowns are enabled. There is no set accessor - this value calculated from the GpioSetting.

value
The PullupsPulldownsEnabled state. Note this does not indicate if the port has a pullup or pulldown configured - just that one or the other is enabled on that port.