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:
- 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.
- 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§
Enums§
Functions§
- init
- Initializes the LPM kernel module.