Skip to main content

Crate ql_gpio

Crate ql_gpio 

Expand description

Pure Rust implementation of ql_peripheral’s GPIO API.

The API is mostly based on Linux’s sysfs GPIO interface, but with two exceptions:

  1. Quectel uses a different GPIO numbering scheme than Linux. The mapping is done internally by the ql_peripheral library.
  2. The sysfs interface doesn’t support setting the pull selection. Quectel’s library writes the pin configuration register of the pin controller of the MDM9607 (TLMM) through /dev/mem. This only works for TLMM GPIOs, not for the GPIOs of the PMIC.

Both of these are re-implemented by this library.

§Example

use ql_gpio::{InputPin, Level, OutputPin, PullSelection, TlmmPin};

let led = OutputPin::new(TlmmPin::Gpio5, false, PullSelection::Disable, Level::Low)?;
let mut button = InputPin::new(TlmmPin::Gpio2, true, PullSelection::PullUp)?;
button.wait_for(Level::High).await?;
led.set_level(Level::High)?;

§Edges

An InputPin waits for the edges that sysfs reports on the value file. It must be created in a Tokio runtime with I/O enabled.

Modules§

ag35 🔒
Pin numbers of Quectel’s ql_gpio.h and their Linux GPIO numbers.
input 🔒
level 🔒
output 🔒
pmic 🔒
sysfs 🔒
Legacy sysfs GPIO interface in /sys/class/gpio.
tlmm 🔒
Pin configuration registers of the MDM9607 TLMM (Top Level Mode Multiplexer).

Structs§

InputPin
Input pin that can wait for a level.
OutputPin
Output pin.

Enums§

Level
Logical level of a pin.
PmicPin
GPIO of the PMIC.
PullSelection
Pull resistor configuration of a GPIO pin.
TlmmPin
GPIO of the TLMM.