pub struct I2cBus(/* private fields */);
Implementations§
Source§impl I2cBus
impl I2cBus
Sourcepub fn from_unit(unit: u32) -> Result<I2cBus, I2cError>
pub fn from_unit(unit: u32) -> Result<I2cBus, I2cError>
Examples found in repository?
examples/mcp.rs (line 15)
12fn main() {
13 let adr = 0x20;
14 use embedded_hal::i2c::blocking::*;
15 let mut iic = freebsd_embedded_hal::I2cBus::from_unit(1).unwrap();
16 iic.write(adr, &[IODIRA, 0]).unwrap(); // A* are outputs
17 iic.write(adr, &[IODIRB, 0xff]).unwrap(); // B* are inputs
18 iic.write(adr, &[GPPUB, 0xff]).unwrap(); // B* are pulled up
19 loop {
20 let mut bank_b: [u8; 1] = [0x69];
21 iic.write_read(adr, &[GPIOB], &mut bank_b).unwrap();
22 eprintln!("GPIOB: {:x} ({:b})", bank_b[0], bank_b[0]);
23 std::thread::sleep(std::time::Duration::from_millis(10));
24 iic.write(adr, &[GPIOA, (bank_b[0] & 1) << 7]).unwrap();
25 std::thread::sleep(std::time::Duration::from_millis(10));
26 }
27}
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<I2cBus, I2cError>
Trait Implementations§
Source§impl FromRawFd for I2cBus
impl FromRawFd for I2cBus
Source§unsafe fn from_raw_fd(fd: RawFd) -> Self
unsafe fn from_raw_fd(fd: RawFd) -> Self
Constructs a new instance of
Self
from the given raw file
descriptor. Read moreSource§impl IntoRawFd for I2cBus
impl IntoRawFd for I2cBus
Source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Consumes this object, returning the raw underlying file descriptor. Read more
Source§impl Transactional for I2cBus
impl Transactional for I2cBus
Source§impl TransactionalIter for I2cBus
impl TransactionalIter for I2cBus
Source§impl WriteIterRead for I2cBus
impl WriteIterRead for I2cBus
Auto Trait Implementations§
impl Freeze for I2cBus
impl RefUnwindSafe for I2cBus
impl Send for I2cBus
impl Sync for I2cBus
impl Unpin for I2cBus
impl UnwindSafe for I2cBus
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