Struct PicoGPIO

Source
pub struct PicoGPIO<Port: SerialPort, const PINS: usize = 256> { /* private fields */ }

Implementations§

Source§

impl<Port: SerialPort, const PINS: usize> PicoGPIO<Port, PINS>

Source

pub fn new(serial_port: Port) -> Result<Self, Error>

Examples found in repository?
examples/audiostreamer.rs (line 9)
5fn main() -> Result<(), serialport::Error> {
6    let port = serialport::new("/dev/ttyACM0", 2000000)
7        .open_native()
8        .unwrap();
9    let mut gpio: PicoGPIO<_> = PicoGPIO::new(port).unwrap();
10    println!("Init...");
11    gpio.init_pwm(115200, 8, true)?;
12    println!("Start...");
13    let mut stream = gpio.audiostream(0).ok().unwrap();
14    println!("Streaming.");
15
16    let mut buf = [0u8; 1024];
17    let mut stdin = stdin().lock();
18    loop {
19        stdin.read_exact(&mut buf).unwrap();
20        stream.submit_data(&buf)?;
21    }
22}
Source

pub fn poll(&mut self, min_lines: usize) -> Result<(), Error>

Source

pub fn set_manual( &mut self, pin: usize, value: PinValueWrite, block: bool, ) -> Result<(), Error>

Source

pub fn get_manual( &mut self, pin: usize, kind: PinInput, cached: bool, block: bool, ) -> Result<PinValueRead, Error>

Source

pub fn float(&mut self, pin: usize) -> Result<(), Error>

Source

pub fn out_d(&mut self, pin: usize, val: bool) -> Result<(), Error>

Source

pub fn out_pwm(&mut self, pin: usize, val: u32) -> Result<(), Error>

Source

pub fn in_float(&mut self, pin: usize) -> Result<bool, Error>

Source

pub fn in_pulldn(&mut self, pin: usize) -> Result<bool, Error>

Source

pub fn in_pullup(&mut self, pin: usize) -> Result<bool, Error>

Source

pub fn in_analog(&mut self, pin: usize) -> Result<u32, Error>

Source

pub fn init_pwm(&mut self, freq: u32, res: u8, block: bool) -> Result<(), Error>

Examples found in repository?
examples/audiostreamer.rs (line 11)
5fn main() -> Result<(), serialport::Error> {
6    let port = serialport::new("/dev/ttyACM0", 2000000)
7        .open_native()
8        .unwrap();
9    let mut gpio: PicoGPIO<_> = PicoGPIO::new(port).unwrap();
10    println!("Init...");
11    gpio.init_pwm(115200, 8, true)?;
12    println!("Start...");
13    let mut stream = gpio.audiostream(0).ok().unwrap();
14    println!("Streaming.");
15
16    let mut buf = [0u8; 1024];
17    let mut stdin = stdin().lock();
18    loop {
19        stdin.read_exact(&mut buf).unwrap();
20        stream.submit_data(&buf)?;
21    }
22}
Source

pub fn pwmstream( self, pin: usize, ) -> Result<PwmStreamer<Port, PINS>, (Self, Error)>

Source

pub fn audiostream( self, pin: usize, ) -> Result<PwmStreamer<Port, PINS>, (Self, Error)>

Examples found in repository?
examples/audiostreamer.rs (line 13)
5fn main() -> Result<(), serialport::Error> {
6    let port = serialport::new("/dev/ttyACM0", 2000000)
7        .open_native()
8        .unwrap();
9    let mut gpio: PicoGPIO<_> = PicoGPIO::new(port).unwrap();
10    println!("Init...");
11    gpio.init_pwm(115200, 8, true)?;
12    println!("Start...");
13    let mut stream = gpio.audiostream(0).ok().unwrap();
14    println!("Streaming.");
15
16    let mut buf = [0u8; 1024];
17    let mut stdin = stdin().lock();
18    loop {
19        stdin.read_exact(&mut buf).unwrap();
20        stream.submit_data(&buf)?;
21    }
22}

Auto Trait Implementations§

§

impl<Port, const PINS: usize> Freeze for PicoGPIO<Port, PINS>
where Port: Freeze,

§

impl<Port, const PINS: usize> RefUnwindSafe for PicoGPIO<Port, PINS>
where Port: RefUnwindSafe,

§

impl<Port, const PINS: usize> Send for PicoGPIO<Port, PINS>

§

impl<Port, const PINS: usize> Sync for PicoGPIO<Port, PINS>
where Port: Sync,

§

impl<Port, const PINS: usize> Unpin for PicoGPIO<Port, PINS>
where Port: Unpin,

§

impl<Port, const PINS: usize> UnwindSafe for PicoGPIO<Port, PINS>
where Port: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.