Hello everyone,
I am trying to implement a wake-up mechanism in my application in Zephyr OS. I have configured an interrupt on a GPIO pin triggered by the fifo overrun event of a lis3dh accelerometer. I want my application to be in sleep mode (SUSPEND_TO_RAM) for most of the time and only be awaken from the trigger of the interrupt. Hereby, it’s how every part is more or less implemented:
Overlay
pins {
compatible = "gpio-keys";
status = "okay";
trigger_pin: trigger_pin {
gpios = <&gpio32_63 6 (GPIO_ACTIVE_HIGH)>;
label = "LIS3DH Interrupt 1";
};
};
GPIO interrupt and callback
triggerPin = GPIO_DT_SPEC_GET(TRIGGER_PIN_NODE, gpios);
if (!gpio_is_ready_dt(&triggerPin)) {
LOG_ERR("[LIS3DHManager] GPIO not ready");
return -ENODEV;
}
ret = gpio_pin_configure_dt(&triggerPin, GPIO_INPUT);
if (ret != 0) {
LOG_ERR("[LIS3DHManager] Failed to configure INT pin: %d", ret);
return ret;
}
LOG_INF("[LIS3DHManager] Linking callback to interrupt");
ret = gpio_pin_interrupt_configure_dt(&triggerPin, GPIO_INT_EDGE_RISING | GPIO_INT_WAKEUP);
if (ret != 0) {
LOG_ERR("[LIS3DHManager] Failed to configure GPIO interrupt: %d", ret);
return ret;
}
ret = pm_device_wakeup_is_capable(triggerPin.port);
if (ret != 0) {
LOG_ERR("[LIS3DHManager] GPIO not eligible as a wake-up source: %d", ret);
return ret;
}
ret = pm_device_wakeup_enable(triggerPin.port, true);
if (ret != 0) {
LOG_ERR("[LIS3DHManager] GPIO wake-up source not enabled: %d", ret);
return ret;
}
ps. I tried to use GPIO_INT_WAKEUP mask and PM APIs (pm_device_wakeup_enable) but it didn’t work anything
Main
int main(void)
{
setup();
#if defined(CONFIG_BT_PERIPHERAL)
int ret = rak_ble_peripheral_init();
if (ret) {
LOG_ERR("Failed to init ble peripheral: %d", ret);
return -1;
}
#endif
while(true) {
MainApp::LIS3DHRun(LIS3DH_FIFO_MODE);
if(accel_sample_event_counter > 2) {
sendClassificationAndGpsData();
accel_sample_event_counter = 0;
}
k_sleep(K_FOREVER);
}
return 0;
}
Has anyone dealt with it somehow?