[−][src]Struct matrix_rhal::Bus
Bridge for talking to the MATRIX Kernel Modules. Most, if not all, MATRIX functionality requires this Bus to read and write data.
Fields
device_file: &'static str
Path for the device file being used. This is what's used to communicate with the MATRIX Kernel.
regmap_fd: RawFd
File descriptor for kernel abstraction.
device_name: Device
Type of MATRIX device that's currently attached.
device_version: u32
The version of the board.
device_leds: u8
Number of LEDS on the MATRIX device.
fpga_frequency: u32
Frequency of the FPGA on the MATRIX device.
Methods
impl Bus
[src]
pub fn init() -> Result<Bus, Error>
[src]
Create, initialize, and return a MATRIX Bus
pub fn write(&self, write_buffer: &mut [u8])
[src]
Send a write buffer to the MATRIX Kernel Modules. The buffer requires an address
to request,
the byte_length
of the data being given, and then the rest of the data itself.
Usage
let some_value: u16 = 237; let mut buffer: [u32; 3] = [0; 3]; // address to query buffer[0] = (fpga_address::GPIO + address_offset) as u32; // byte length of data (u16 = 2 bytes) buffer[1] = 2; // data being sent buffer[2] = some_value as i32; // send buffer self.bus.write(unsafe { std::mem::transmute::<&mut [u32], &mut [u8]>(&mut buffer) });
pub fn read(&self, read_buffer: &mut [u8])
[src]
Send a read buffer to the MATRIX Kernel Modules. The buffer requires an address
to request and
the byte_length
of what's expected to be returned. Once sent, the buffer return with populated
data.
Keep in mind, the returned buffer will still have the address
and byte_length
that was passed.
Usage
let mut buffer: [u32; 4] = [0; 4]; // address to query buffer[0] = (fpga_address::CONF) as u32; // bytes being requested buffer[1] = 8; // populate buffer bus.read(unsafe { std::mem::transmute::<&mut [u32], &mut [u8]>(buffer) }); // returned data will start at buffer[2] println!("{:?}", buffer);
pub fn close(&self)
[src]
Close the file descriptor that's communicating with the MATRIX Kernel's device file.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bus
impl Send for Bus
impl Sync for Bus
impl Unpin for Bus
impl UnwindSafe for Bus
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,