can't go into ship mode outside of an event handler

Using code from the npm13xx_one_button sample, going into ship mode from event_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) works fine on a button release with the following function call:

regulator_parent_ship_mode(regulators)            //static const struct device *regulators = NPM13XX_DEVICE(regulators);
However, I need to go into ship mode after a long button press without a release. So I set a timer on the button press, and call that same function from my timer handler but the device doesn't go into ship mode. I suspect that it's because the parent is only 'known' inside the handler. 
is there a way to make the parent available outside the handler? or is there another way to go into ship mode without a parent (since my board only seems to have one regulator). 
Thank you.
Parents Reply Children
  • That's great.

    I suspect that it's because the parent is only 'known' inside the handler. 

    This is not the case. 

    Since the SHPHLD button is also used to wake up the device, we guess what you are experiencing is that the regulator_parent_ship_mode call succeeds, but the device immediately wakes up since the button remains pressed (wakeup is level-triggered).
    If you want a power off button-like behaviour, you could utilize one of the GPIOs to do that if available. One could get fall/rise events on any GPIO too.

    -Priyanka

Related