pub struct Gpio { /* private fields */ }
Implementations§
Source§impl Gpio
impl Gpio
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Create a new handle to the GPIO peripheral.
This will attempt to map a portion of /dev/mem, in order to access the memory mapped GPIO peripheral.
This may fail if:
- we don’t have root permission.
- the kernel was compiled with CONFIG_IO_STRICT_DEVMEM.
- the kernel was compiled with CONFIG_STRICT_DEVMEM,
and not started with
iomem=relaxed
on the kernel command line.
Sourcepub fn control_block(&self) -> *mut c_void
pub fn control_block(&self) -> *mut c_void
Get the pointer to the mapped control block.
Sourcepub fn read_register(&self, reg: Register) -> u32
pub fn read_register(&self, reg: Register) -> u32
Read a value from a register.
Sourcepub unsafe fn write_register(&mut self, reg: Register, value: u32)
pub unsafe fn write_register(&mut self, reg: Register, value: u32)
Write a value to a register.
Sourcepub unsafe fn and_register(&mut self, reg: Register, value: u32)
pub unsafe fn and_register(&mut self, reg: Register, value: u32)
Perform an atomic bitwise AND on the contents of a register.
Sourcepub unsafe fn or_register(&mut self, reg: Register, value: u32)
pub unsafe fn or_register(&mut self, reg: Register, value: u32)
Perform an atomic bitwise OR on the contents of a register.
Sourcepub unsafe fn xor_register(&mut self, reg: Register, value: u32)
pub unsafe fn xor_register(&mut self, reg: Register, value: u32)
Perform an atomic bitwise XOR on the contents of a register.
Sourcepub fn read_level(&self, index: usize) -> bool
pub fn read_level(&self, index: usize) -> bool
Read the current level of a GPIO pin.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gpio
impl RefUnwindSafe for Gpio
impl !Send for Gpio
impl !Sync for Gpio
impl Unpin for Gpio
impl UnwindSafe for Gpio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more