Crate ql_lpm

Crate ql_lpm 

Expand description

Library for interacting with Quectel’s LPM kernel module.

You can find the kernel module at <ql-ol-kernel/drivers/quectel-drivers/ql_lpm/ql_lpm.c>.

Even though the name seems to imply that this module is for low power mode, it is only tangentially related. The module does two things:

  1. It allows userspace to attach an interrupt to an input pin so that this pin can be used to wake up the system from suspend.
  2. Additionally, an output pin can be configured to be set to a desired value when the system is suspended. This can be used to automatically turn off another device when the system is suspended.

For the TCUv4 we’re using the feature so the NXP can wake the AG35 and the AG35 can turn off the NXP when going to sleep.

§Example

let config = ql_lpm::Config {
    input_pin: ql_gpio::PinName::Gpio2,
    input_pull_selection: ql_gpio::PullSelection::PullUp,
    output_pin: ql_gpio::PinName::Gpio5,
    output_edge: ql_lpm::Edge::Rising,
};
let mut lpm = ql_lpm::init(&config).await.unwrap();
loop {
    let edge = lpm.next().await.unwrap();
    println!("Edge: {:?}", edge);
}

§Technical details

The initial configuration containing the pins is given to the module as parameters. Once the module is loaded, a netlink socket is used to communicate with the module. The kernel module expects a netlink message to find out which PID to send events to. Only one process can receive events. The module will then send messages containing the payload “falling” or “rising” to the listening process whenever the input pin changes its state.

Modules§

kernel_module 🔒 Linux or Android
netlink 🔒 Linux or Android

Structs§

Config
Configuration for the LPM kernel module.
Lpm
Connection to the LPM kernel module.

Enums§

Edge

Functions§

init
Initializes the LPM kernel module.