Disabling/enabling hardware components at runtime

Dear All,

I need to implement fully disabling and enabling several hardware components and drivers (UART, comparator, PWW, etc.) that I'll need only when the user asks for certain functions of the device. I'm using SDK V2.6.0, which, if I'm not wrong, ships Zephyr 3.1.0.

I found function pm_device_action_run(...) seems to be the way to go, but I need to know the steps I need to follow o do it right. What I want is to fully disable the device at runtime (OFF) and, when needed, enable and use it, then disable again after disconnection from peer.

Thanks.

  • Hi,

    In some cases the device power management module will call nrfx uninit function of the device peripheral when you run pw_device_action_run() with SUSPEND.

    In some cases there is no implementation of the SUSPEND task for the peripheral which means that it will have no effect for that device. Therefore, I suggest using nrfx directly and call the uninit function of each peripheral when you're done using them. Same goes for init. 

    See this sample,

    regards

    Jared 

  • Hi,

    Thanks Jared.

    For the Uart, I ended up with calls to pm_device_action_run() with actions PM_DEVICE_ACTION_SUSPEND and PM_DEVICE_ACTION_RESUME. Actions PM_DEVICE_ACTION_TURN_OFF/ON are not implemented for the Uart.

    I bookmarked the example from your answer for just in case I needed in the future.

    BR

Related