This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Restart external sensors within Zephyr without restarting the firmware

We have a hardware with a few external sensors and devices, such as displays, accelerometers, etc.

These devices are initialized within Zephyr, before our main loop.

For ultra low power, our hardware can disable (actually shutdown the circuit that powers these devices), while the MCU is still working (on a low power state, for example). When some event happens, we want to enable the external devices (turn their power on) - but their instantiation in Zephyr had already occurred, hence from the firmware point of view they are not working anymore - I'd need a full boot of the MCU.

This seems to be quite an ordinary application, but we couldn't figure the proper way of doing this "peripheral reinitialization" without rebooting the MCU. How do we go about it?

Thanks

Bruno

Parents
  • Hi Bruno,

    Have you looked into the device specific power management events?

    When the device goes to sleep you change its power state from applicaiton:
    device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE, NULL, NULL); 
    When you want to turn it again you do the same but with DEVICE_PM_ACTIVE_STATE.
    The issue here is that the underlying device driver might not have taken into considerations that this power events will reset the device/sensors registers and need a reconfiguration, so you might have to patch the underlying device driver to handle this event to reconfigure the devices/sensors again.
Reply
  • Hi Bruno,

    Have you looked into the device specific power management events?

    When the device goes to sleep you change its power state from applicaiton:
    device_set_power_state(dev, DEVICE_PM_SUSPEND_STATE, NULL, NULL); 
    When you want to turn it again you do the same but with DEVICE_PM_ACTIVE_STATE.
    The issue here is that the underlying device driver might not have taken into considerations that this power events will reset the device/sensors registers and need a reconfiguration, so you might have to patch the underlying device driver to handle this event to reconfigure the devices/sensors again.
Children
Related