/*
 * Copyright (c) 2024 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/ {
	chosen {
		ncs,sm-uart = &dtr_uart2;
	};
};

&uart0 {
	status = "disabled";
};

/* DTR with external MCU */
&uart2 {
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	hw-flow-control;
	status = "okay";

	dtr_uart2: dtr-uart {
		compatible = "nordic,dtr-uart";
		dtr-gpios = <&gpio0 31 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
		ri-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
	pinctrl-0 = <&uart2_default_alt>;
	pinctrl-1 = <&uart2_sleep_alt>;
	pinctrl-names = "default", "sleep";
};

&gpio0 {
	status = "okay";
	/* Use PORT event for DTR (31) pin to save power */
	sense-edge-mask = <0x80000000>;
};

&pinctrl {
	uart2_default_alt: uart2_default_alt {
		group1 {
			psels = <NRF_PSEL(UART_RX, 0, 27)>,
				<NRF_PSEL(UART_CTS, 0, 14)>;
			bias-pull-up;
		};
		group2 {
			psels = <NRF_PSEL(UART_TX, 0, 26)>,
				<NRF_PSEL(UART_RTS, 0, 15)>;
		};
	};

	uart2_sleep_alt: uart2_sleep_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 26)>,
				<NRF_PSEL(UART_RX, 0, 27)>,
				<NRF_PSEL(UART_RTS, 0, 15)>,
				<NRF_PSEL(UART_CTS, 0, 14)>;
			low-power-enable;
		};
	};
};
