/*
 * Copyright (c) 2017 Shawn Nock <shawn@monadnock.ca>
 * Copyright (c) 2017 Linaro Limited
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/dts-v1/;
#include <nordic/nrf52832_qfaa.dtsi>
#include "nrf52dk_nrf52832-pinctrl.dtsi"

/ {
	model = "Nordic nRF52 DK NRF52832";
	compatible = "nordic,nrf52-dk-nrf52832";

	chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,bt-mon-uart = &uart0;
		zephyr,bt-c2h-uart = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
	};

	/* These aliases are provided for compatibility with samples */
	aliases {
		// led0 = &led0;
		// led1 = &led1;
		// led2 = &led2;
		// led3 = &led3;
		// pwm-led0 = &pwm_led0;
		// sw0 = &button0;
		// sw1 = &button1;
		// sw2 = &button2;
		// sw3 = &button3;
		// bootloader-led0 = &led0;
		// mcuboot-button0 = &button0;
		// mcuboot-led0 = &led0;
		watchdog0 = &wdt0;
	};
};

&adc {
	status = "okay";
};

&gpiote {
	status = "okay";
};

&gpio0 {
	status = "okay";
};

&uart0 {
	status = "okay";
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	pinctrl-0 = <&uart0_default>;
	pinctrl-1 = <&uart0_sleep>;
	pinctrl-names = "default", "sleep";
};

&pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 20)>,
				<NRF_PSEL(UART_RX, 0, 19)>;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 20)>,
				<NRF_PSEL(UART_RX, 0, 19)>;
			low-power-enable;
		};
	};

	spi0_default: spi0_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 17)>,
				<NRF_PSEL(SPIM_MOSI, 0, 16)>,
				<NRF_PSEL(SPIM_MISO, 0, 15)>;
		};
	};

	spi0_sleep: spi0_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 17)>,
				<NRF_PSEL(SPIM_MOSI, 0, 16)>,
				<NRF_PSEL(SPIM_MISO, 0, 15)>;
			low-power-enable;
		};
	};

	spi1_default: spi1_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 7)>,
				<NRF_PSEL(SPIM_MOSI, 0, 6)>,
				<NRF_PSEL(SPIM_MISO, 0, 3)>;
		};
	};

	spi1_sleep: spi1_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 7)>,
				<NRF_PSEL(SPIM_MOSI, 0, 6)>,
				<NRF_PSEL(SPIM_MISO, 0, 3)>;
			low-power-enable;
		};
	};
};

&spi0 {
	//	compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi0_default>;
	pinctrl-1 = <&spi0_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
	spi0_cs: spi0_cs@0 {
		reg = <0>;
	};
};
	
// &spi1 {
// 	// compatible = "nordic,nrf-spim";
// 	status = "okay";
// 	pinctrl-0 = <&spi1_default>;
// 	pinctrl-1 = <&spi1_sleep>;
// 	pinctrl-names = "default", "sleep";
//  	cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
//  	spi1_cs: spi1_cs@0 {
//  		reg = <0>;
//  	};
// };

&flash0 {

	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0x0000C000 0x37000>;
		};
		slot1_partition: partition@43000 {
			label = "image-1";
			reg = <0x00043000 0x37000>;
		};
		storage_partition: partition@7a000 {
			label = "storage";
			reg = <0x0007a000 0x00006000>;
		};
	};
};
