SDK: 2.6.1
I needed to add a single wire support to our device recently and I did that by using two pins TX/RX shorted and UART. It works, but current consumption sky rockets because of the UART. After some googling I decided that putting uart to suspended state should be the correct thing to do to fix that.
// single wire communication is done const struct device* const dev = DEVICE_DT_GET(DT_NODELABEL(uart1)); ... int err = pm_device_action_run(dev, on ? PM_DEVICE_ACTION_RESUME : PM_DEVICE_ACTION_SUSPEND); ...
And it does. But then I noticed that when I call this API some seemingly unrelated GPIOs switch state. Why on earth is that and what can I do about it?
This is my pin device tree
&pinctrl {
...
uart1_default: uart1_default {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 0)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_TX, 0, 3)>;
/* max. 5mA drive strength: */
/*nordic,drive-mode = <NRF_DRIVE_H0D1>;*/
};
};
};
&arduino_serial {
status = "okay";
w1_0: w1-zephyr-serial-0 {
compatible = "zephyr,w1-serial";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
ds18b20 {
compatible = "maxim,ds18b20";
family-code = <0x28>;
resolution = <12>;
status = "okay";
};
};
};And this is what I do somewhere before calling the PM API. GPIO is set correctly and stays set until about 2 minutes later when serial is put to suspended this GPIO also switches state
#define ENABLE_GAS_PIN 28 ... gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0)); err = gpio_pin_configure(gpio_dev, ENABLE_GAS_PIN, GPIO_OUTPUT_LOW | GPIO_ACTIVE_HIGH); ... err = gpio_pin_set(gpio_dev, ENABLE_GAS_PIN, 1);
I found this old post. Someone had a similar problem but there is no solution devzone.nordicsemi.com/.../how-to-enable-disable-the-uart-with-ncs-zephyr