Enum jetson_gpio::Mode
source · pub enum Mode {
BOARD,
BCM,
}
Expand description
Specifies the pin numbering mode.
The pin numbering mode is used to determine the mapping between the pin numbers and the GPIO channels. The pin numbering mode can be one of the following:
BOARD
- The pin numbers are the physical pin numbers on the Jetson board.BCM
- The pin numbers are the Broadcom SOC channel numbers.TEGRA_SOC
- The pin numbers are the Tegra SOC channel numbers.CVM
- The pin numbers are the CVM channel numbers.
Example
use jetson_gpio::{GPIO, Mode};
let mut gpio = GPIO::new();
gpio.setmode(Mode::BOARD).unwrap();
Variants§
Implementations§
source§impl Mode
impl Mode
sourcepub fn from_str(s: &str) -> Result<Mode>
pub fn from_str(s: &str) -> Result<Mode>
Converts a string to a Mode
enum.
Valid strings are:
"BOARD"
"BCM"
"TEGRA_SOC"
CVM
Example
use jetson_gpio::{GPIO, Mode};
let mut gpio = GPIO::new();
gpio.setmode(Mode::from_str("BOARD").unwrap()).unwrap();
sourcepub fn to_str(&self) -> &str
pub fn to_str(&self) -> &str
Converts a Mode
enum to a string.
Example
use jetson_gpio::{GPIO, Mode};
let mut gpio = GPIO::new();
gpio.setmode(Mode::BOARD).unwrap();
assert_eq!(gpio.getmode().unwrap().to_str(), "BOARD");
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks if the Mode
is valid.
Example
use jetson_gpio::{GPIO, Mode};
let mut gpio = GPIO::new();
assert_eq!(Mode::BOARD.is_valid(), true);
assert_eq!(Mode::BCM.is_valid(), true);
assert_eq!(Mode::TEGRA_SOC.is_valid(), false);
assert_eq!(Mode::CVM.is_valid(), false);