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

 /*
  * DTS overlay to be used when connecting nRF9160 DK with ESP8266-01 using
  * the esp_at driver.
  *
  * https://en.wikipedia.org/wiki/ESP8266
  *
  * Wiring:
  * - Slide (SW9) to enable 3V mode.
  * - ESP8266 RX → DK P0.10 (TX)
  * - ESP8266 TX → DK P0.16 (RX)
  * - ESP8266 VCC → DK VDD
  * - ESP8266 CH_PD → DK VDD
  * - ESP8266 GND → DK GND.
  *
  * Compilation with SW overlay:
  * 'west build -p -b nrf9160dk_nrf9160_ns -- -DDTC_OVERLAY_FILE=esp_8266_nrf9160ns.overlay -DOVERLAY_CONFIG="overlay-esp-wifi.conf"'
  */

&uart3 {
	status = "okay";
	current-speed = <115200>;

	pinctrl-0 = <&uart3_default_alt>;
	pinctrl-1 = <&uart3_sleep_alt>;
	pinctrl-names = "default", "sleep";
	esp8266: esp8266 {
		compatible = "espressif,esp-at";
		status = "okay";
	};
};

&pinctrl {
	uart3_default_alt: uart3_default_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 10)>,
				<NRF_PSEL(UART_RX, 0, 16)>;
		};
	};

	uart3_sleep_alt: uart3_sleep_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 10)>,
				<NRF_PSEL(UART_RX, 0, 16)>;
			low-power-enable;
		};
	};

};

/ {
	chosen {
		ncs,location-wifi = &esp8266;
	};
};
