[][src]Struct dma_gpio::pi::Board

pub struct Board { /* fields omitted */ }

Struct for dealing with GPIO Pins.

Board is initialized through BoardBuilder.

Note that you can only manipulate pins that are set from BoardBuilder,

so if the pin you want to access is not one of the default pins: [4, 17, 18, 27, 21, 22, 23, 24, 25], make sure to set it with BoardBuilder::build_with_pins.

Example

This example uses pins [21, 22, 23],

sets pin 21 to 25%, pin 22 to 50%, and pin 23 to 75%,

then, after 1 second, releases pin 22,

then, after 1 second, release all pins.

use std::thread::sleep;
use std::time::Duration;
use dma_gpio::pi::BoardBuilder;
 
fn main() {
    let mut board = BoardBuilder::new().build_with_pins(vec![21, 22, 23]).unwrap();
    board.print_info();
     
    board.set_pwm(21, 0.25).unwrap();
    board.set_pwm(22, 0.50).unwrap();
    board.set_pwm(23, 0.75).unwrap();
     
    let sec = Duration::from_millis(1000);
    sleep(millis);
     
    board.release_pwm(22).unwrap();
     
    sleep(millis);
     
    board.release_all_pwm().unwrap();
     
}
 

Methods

impl Board[src]

pub fn set_pwm(&mut self, pin: u8, width: f32) -> Result<(), Error>[src]

Set GPIO pin's pwm width.

pub fn set_all_pwm(&mut self, width: f32) -> Result<(), Error>[src]

Set all known GPIO pins' pwm width.

pub fn set_invert_mode(&mut self, mode: bool)[src]

Invert all known GPIO pins' outputs.

pub fn release_pwm(&mut self, pin: u8) -> Result<(), Error>[src]

Releases GPIO pin.

pub fn release_all_pwm(&mut self) -> Result<(), Error>[src]

Releases all GPIO pins.

pub fn is_known_pin(&self, pin: u8) -> bool[src]

Check if the pin provided is found in the list of known pins set with BoardBuilder::build_with_pins.

pub fn is_banned_pin(&self, pin: u8) -> bool[src]

Check if the pin provided is found in the list of BANNED pins.

pub fn terminate(&mut self)[src]

Sets all GPIO pins' pwm width to 0.0, and frees the memory used for the process.

Board already implements Drop trait that calls this method, so you won't ever have to call this method.

pub fn print_info(&self)[src]

print info about the hardware: PWM or PCM, Number of channels, Pins being used, PWM Frequency, PWM steps, Maximum Period, Minimum Period, and DMA Base Address.

pub fn debug_dump_hw(&self)[src]

This method is only available when 'debug' feature is on.

Print out all informations about the control blocks, PWM, Clock, GPIO and DMA.

pub fn debug_dump_samples(&self)[src]

This method is only available when 'debug' feature is on.

Print out info about samples' outputs.

Trait Implementations

impl Drop for Board[src]

Auto Trait Implementations

impl !Sync for Board

impl !Send for Board

impl Unpin for Board

impl !RefUnwindSafe for Board

impl !UnwindSafe for Board

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]