Describe the various attributes of an individual General-Purpose Input/Output (GPIO) pin. GPIO pin functions include Digital Input / Output, PWM Output and Analog Input / Output.
Always access instances of this class via the
BoardPinInfo
accessor methods rather
than constructing instances yourself. For example,
BoardPinInfo.getByGpioNumber(gpio)
and
BoardPinInfo.getByChipAndLineOffset(chip, lineOffset)
.
A board has a number of headers, each header has a number of physical pins connected to it. For example, the Raspberry Pi model B has the main 40-pin J8 header as well as the 8-pin P5 header (that doesn't have header pins soldered by default). Non-GPIO pins such as Vcc and GND are also included for information purposes only.
A pin has the following attributes:
- keyPrefix
- internal only attribute used by
AbstractDeviceFactory
when provisioning GPIO devices - header
- the name of the board header to which this pin is attached
- physicalPin
- the physical header pin number
- deviceNumber
- the logical device GPIO number
- sysFsNumber
- typically the same as the GPIO / device number; can be different for PWM pins that are controlled via Linux sysfs
- chip
- the Linux GPIO chip number for this GPIO as defined by the Linux GPIO
character device; see /sys/gpiochip<n>, run
gpiodetect
to list - lineOffset
- the line number offset for this GPIO on the GPIO chip - Linux GPIO
character device;
run gpioinfo <n>
to list - name
- the name of this pin
- modes
- the set of valid
modes
for this pin
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final String
static final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final EnumSet<DeviceMode>
static final String
static final int
static final EnumSet<DeviceMode>
static final String
static final String
-
Constructor Summary
ConstructorDescriptionPinInfo
(String keyPrefix, String header, int deviceNumber, int physicalPin, int pwmChip, int pwmNum, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line, float adcVRef) PinInfo
(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes) PinInfo
(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, float adcVRef) PinInfo
(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line) -
Method Summary
Modifier and TypeMethodDescriptionfloat
int
getChip()
the Linux GPIO chip number for this GPIO as defined by the Linux GPIO character device; see /sys/gpiochip<n>, rungpiodetect
to listint
Get the logical device GPIO numberGet the name of the board header to which this pin is attachedInternal only attribute used byAbstractDeviceFactory
when provisioning GPIO devicesint
Get the line number offset for this GPIO on the GPIO chip - Linux GPIO character device;run gpioinfo <n>
to listgetModes()
Get the set of validmodes
for this pingetName()
Get the name of this pinint
Get the physical header pin numberint
int
int
Get sysfs number for this pin.boolean
boolean
boolean
boolean
boolean
boolean
boolean
isSupported
(DeviceMode mode) Check if the specifiedmode
is supported by this pinvoid
setChip
(int chip) Internal method - do not callvoid
setLineOffset
(int lineOffset) Internal method - do not calltoString()
void
updateGpioChipId
(int oldChipId, int newChipId)
-
Field Details
-
DIGITAL_IN
-
DIGITAL_OUT
-
DIGITAL_IN_OUT
-
DIGITAL_IN_OUT_PWM
-
PWM_OUTPUT
-
DIGITAL_PWM_OUTPUT
-
DIGITAL_ANALOG_INPUT
-
ANALOG_INPUT
-
ANALOG_OUTPUT
-
NOT_DEFINED
public static final int NOT_DEFINED- See Also:
-
DEFAULT_HEADER
- See Also:
-
GROUND
- See Also:
-
VCC_5V
- See Also:
-
VCC_3V3
- See Also:
-
-
Constructor Details
-
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes) -
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, float adcVRef) -
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line) -
PinInfo
public PinInfo(String keyPrefix, String header, int deviceNumber, int physicalPin, int pwmChip, int pwmNum, String name, Collection<DeviceMode> modes, int sysFsNumber, int chip, int line, float adcVRef)
-
-
Method Details
-
getKeyPrefix
Internal only attribute used byAbstractDeviceFactory
when provisioning GPIO devices- Returns:
- the key prefix for this pin
-
getHeader
Get the name of the board header to which this pin is attached- Returns:
- the header name to which this pin is attached
-
getPhysicalPin
public int getPhysicalPin()Get the physical header pin number- Returns:
- the physical header pin number
-
getDeviceNumber
public int getDeviceNumber()Get the logical device GPIO number- Returns:
- the logical device GPIO number
-
getSysFsNumber
public int getSysFsNumber()Get sysfs number for this pin. This is typically the same as the GPIO / device number; can be different for PWM pins that are controlled via Linux sysfs- Returns:
- the sysfs number for this pin
-
getChip
public int getChip()the Linux GPIO chip number for this GPIO as defined by the Linux GPIO character device; see /sys/gpiochip<n>, rungpiodetect
to list- Returns:
- the GPIO chip number for this pin
-
setChip
public void setChip(int chip) Internal method - do not call- Parameters:
chip
- the GPIO chip number for this pin
-
getLineOffset
public int getLineOffset()Get the line number offset for this GPIO on the GPIO chip - Linux GPIO character device;run gpioinfo <n>
to list- Returns:
- the GPIO line offset
-
setLineOffset
public void setLineOffset(int lineOffset) Internal method - do not call- Parameters:
lineOffset
- the GPIO chip line offset number for this pin
-
getName
Get the name of this pin- Returns:
- the name of this pin
-
getModes
Get the set of validmodes
for this pin- Returns:
- the set of valid
modes
for this pin
-
isSupported
Check if the specifiedmode
is supported by this pin- Parameters:
mode
- thedevice mode
to check- Returns:
- true if the device mode is supported
-
isDigitalInputSupported
public boolean isDigitalInputSupported() -
isDigitalOutputSupported
public boolean isDigitalOutputSupported() -
isPwmOutputSupported
public boolean isPwmOutputSupported() -
isServoSupported
public boolean isServoSupported() -
isAnalogInputSupported
public boolean isAnalogInputSupported() -
isAnalogOutputSupported
public boolean isAnalogOutputSupported() -
getPwmChip
public int getPwmChip() -
getPwmNum
public int getPwmNum() -
getAdcVRef
public float getAdcVRef() -
toString
-
updateGpioChipId
public void updateGpioChipId(int oldChipId, int newChipId)
-