#include <zephyr/dt-bindings/led/led.h>

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

dozee_sheet_smallsection: &uart1 {
	status = "okay";
	current-speed = <115200>;
	pinctrl-0 = <&uart1_default>;
	pinctrl-1 = <&uart1_sleep>;
	pinctrl-names = "default", "sleep";
};

&spi2 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi2_default>;
	pinctrl-1 = <&spi2_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;

	sdhc0: sdhc@0 {
			compatible = "zephyr,sdhc-spi-slot";
			reg = <0>;
			status = "okay";
			mmc {
				compatible = "zephyr,sdmmc-disk";
				status = "okay";
                disk-name = "SD";
			};
			spi-max-frequency = <24000000>;
	};
};

&i2c3 {
	status = "okay";
	label = "I2C_3";
	pinctrl-0 = <&i2c3_default>;
	pinctrl-1 = <&i2c3_sleep>;
	pinctrl-names = "default", "sleep";
	clock-frequency = <1000000>;
	
	/* RTC driver */
	rvrtc: rvrtc3028@52{
        compatible = "i2c-device";
        status = "okay";
        reg = < 0x52 >;
	};

	lp5009@14 {
		compatible = "ti,lp5009";
		reg = <0x14>;

		led_0 {
			label = "LED LP5030 0";
			index = <0>;
			color-mapping =
				<LED_COLOR_ID_RED>,
				<LED_COLOR_ID_GREEN>,
				<LED_COLOR_ID_BLUE>;
		};
		led_1 {
			label = "LED LP5030 1";
			index = <1>;
			color-mapping =
				<LED_COLOR_ID_RED>,
				<LED_COLOR_ID_GREEN>,
				<LED_COLOR_ID_BLUE>;
		};
		led_2 {
			label = "LED LP5030 2";
			index = <2>;
			color-mapping =
				<LED_COLOR_ID_RED>,
				<LED_COLOR_ID_GREEN>,
				<LED_COLOR_ID_BLUE>;
		};
	};
};


arduino_spi: &spi4 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;  /* D10 */
	pinctrl-0 = <&spi4_default>;
	pinctrl-1 = <&spi4_sleep>;
	pinctrl-names = "default", "sleep";

	nrf70: nrf7002-spi@0 {
		compatible = "nordic,nrf7002-spi";
		status = "okay";
		reg = <0>;
		spi-max-frequency = <DT_FREQ_M(32)>;
        
        iovdd-ctrl-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
		bucken-gpios = <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;        /* D1 */
		host-irq-gpios = <&gpio0 23 (GPIO_ACTIVE_HIGH)>;     /* D7 */
    };
};


&pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 31)>;
		};
		group2 {
			psels = <NRF_PSEL(UART_RX, 1, 10)>;
			bias-pull-up;
		};
	};

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

	uart1_default: uart1_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 1, 14)>;
		};
		group2 {
			psels = <NRF_PSEL(UART_RX, 1, 15)>;
			bias-pull-up;
		};
	};

	uart1_sleep: uart1_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 1, 14 )>,
				<NRF_PSEL(UART_RX, 1, 15)>;
			low-power-enable;
		};
	};

	spi2_default: spi2_default {
		group1 {
		    psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
			<NRF_PSEL(SPIM_MOSI, 1, 12)>,
			<NRF_PSEL(SPIM_MISO, 1, 11)>;
		};
	};

	spi2_sleep: spi2_sleep {
		group1 {
		    psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
			<NRF_PSEL(SPIM_MOSI, 1, 12)>,
			<NRF_PSEL(SPIM_MISO, 1, 11)>;
		    low-power-enable;
		};
	};

	i2c3_default: i2c3_default{
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 1, 2)>,
				<NRF_PSEL(TWIM_SCL, 1, 3)>;
			// bias-pull-up;
		};
	};

	i2c3_sleep: i2c3_sleep{
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 1, 2)>,
				<NRF_PSEL(TWIM_SCL, 1, 3)>;
			low-power-enable;
		};
	};

	spi4_default: spi4_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK,  0, 8)>,
				<NRF_PSEL(SPIM_MISO, 0, 10)>,
				<NRF_PSEL(SPIM_MOSI, 0, 9)>;
		};
	};

	spi4_sleep: spi4_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK,  0, 8)>,
				<NRF_PSEL(SPIM_MISO, 0, 10)>,
				<NRF_PSEL(SPIM_MOSI, 0, 9)>;
			low-power-enable;
		};
	};

};

/ {
	aliases {
		tx = &led0;
		led1 = &led1;
		led2 = &led2;
		rx = &button0;
		sw1 = &button1;
		bgsection = &bigsection_mux;
		smsection = &smallsection_mux;
		sdcardplug = &sdcard_plug;
		sheetdetectpin = &sheet_detect_pin;
	};

	chosen {
		zephyr,console = &uart0;
		zephyr,wifi = &wlan0;
		nordic,pm-ext-flash = &mx25r64;
		zephyr,uart-mcumgr = &uart1;
		mcuboot-button0 = &button1;
		mcuboot-led0 = &led2;
	};

	gpio_fwd: nrf-gpio-forwarder {
		compatible = "nordic,nrf-gpio-forwarder";
		status = "okay";
		uart {
				gpios = <&gpio1 14 0>, <&gpio1 15 0>;
		};
	};


    nrf_radio_coex: coex {
		status = "okay";
        compatible = "nordic,nrf7002-coex";
		status0-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; /* D2 */
		req-gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>; /* D3 */
		grant-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_LOW)>; /* D4 */
		swctrl1-gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; /* D6 */
        // srrf-switch-gpios = <&arduino_header 14 GPIO_ACTIVE_HIGH>;  /* D8 */
	};

	leds {
		compatible = "gpio-leds";

		led0: led_0 {
			gpios = <&gpio1 7 (GPIO_PULL_UP)>;
			label = "Green LED 0";
		};

		led1: led_1 {
			gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
			label = "Green_LED_1";
		};

		led2: led_2 {
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			label = "Green_LED_2";
		};
	};

	buttons {
		compatible = "gpio-keys";
		button0: button_0 {
			gpios = <&gpio1 9 (GPIO_PULL_UP)>;
			label = "Push button 1";
		};

		button1: button_1 {
			gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
			label = "Push_button_1";
		};

	};

	sheetsections {
		compatible = "gpio-keys";
		bigsection_mux: bigsection_mux {
			gpios = <&gpio0 4 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
					<&gpio0 5 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
					<&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>;
		};

		smallsection_mux: smallsection_mux {
			gpios = <&gpio1 4 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
					<&gpio1 6 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
					<&gpio0 21 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>;
		};
	};

	sdcardplug {
		compatible = "gpio-keys";
		sdcard_plug: sdcard_plug {
			gpios = < &gpio0 7 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>;
		};
	};

	sheetdetectpin {
		compatible = "gpio-keys";
		sheet_detect_pin: sheet_detect_pin
		{
			gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
			label = "SHEET DETECT PIN";
		};
	};

};	

&i2c1 {
    status = "disabled";
};

&mx25r64{
	status = "okay";
};

&qspi {
	status = "okay";
};

&adc {
    status = "okay";
    compatible = "nordic,nrf-saadc";
};

&gpiote {
    status = "okay";
};

&gpio_fwd {
    status = "okay";
};

&pwm0 {
	status = "disabled";
};