does zephyr i2c driver for nrf5340 support pm "TURN_OFF"?

We have a custom nrf5340 based board which has a couple of i2C sensors. The i2c device & the sensors are only required when a BLE connection is active. So ideally we would like to switch off the i2C device and the sensors when no BLE connection is active. The sensors are no problem as they all have a "power down" mode (which we use). However, the i2c device seems to consume at least 300uA after it has been initialized. So we would like to "un-initialize" it or somehow switch it off.

We are using SDK v1.9.1 and have tried the following to code switch off the i2C device:

int power_on_i2c() {
return pm_device_action_run(i2c_dev, PM_DEVICE_ACTION_TURN_OFF);
}
However, we get a -134 return code (which means "ACTION NOT SUPPORTED") when we execute the above function.
So my question is:
1. Is it possible to disable or power-off the i2c device after it has been initialized?
2. If yes, what is the correct way to do that?
Thanks!
 
Gerard.
  • Hi,

     

    We have a custom nrf5340 based board which has a couple of i2C sensors. The i2c device & the sensors are only required when a BLE connection is active. So ideally we would like to switch off the i2C device and the sensors when no BLE connection is active. The sensors are no problem as they all have a "power down" mode (which we use). However, the i2c device seems to consume at least 300uA after it has been initialized. So we would like to "un-initialize" it or somehow switch it off.

    We are using SDK v1.9.1 and have tried the following to code switch off the i2C device:

    int power_on_i2c() {
    return pm_device_action_run(i2c_dev, PM_DEVICE_ACTION_TURN_OFF);
    }
    However, we get a -134 return code (which means "ACTION NOT SUPPORTED") when we execute the above function.
    So my question is:
    1. Is it possible to disable or power-off the i2c device after it has been initialized?
    2. If yes, what is the correct way to do that?

    Yes, it is possible, but you have to use the PM_DEVICE_ACTION_SUSPEND and _RESUME. Here's the functions that are effectively executed for a I2C device:

    https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/drivers/i2c/i2c_nrfx_twim.c#L300-L310

     

    Please note that you might want to keep pull-ups on these lines, depending on the power-down mode of your external sensors.

     

    Kind regards,

    Håkon

Related