/*
 * Copyright (c) 2021-2022 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

 #include <zephyr/dt-bindings/ipc_service/static_vrings.h>

 / {
	 chosen {
		 nordic,pm-ext-flash = &mx25r64;
	 };
 
	 /*
	 * By default, PWM module is only configured for led0 (LED1 on the board).
	 * The lighting-app, however, uses LED2 to show the state of the lighting,
	 * including its brightness level.
	 */
	 aliases {
		 pwm-led1 = &pwm_led1;
	 };
 
	 pwmleds {
		 compatible = "pwm-leds";
		 pwm_led1: pwm_led_1 {
			 pwms = < &pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
		 };
	 };
 };
 
 &ipc0 {
	 zephyr,priority = <0 PRIO_COOP>;
 };
 
 &pwm0 {
	 pinctrl-0 = <&pwm0_default_alt>;
	 pinctrl-1 = <&pwm0_sleep_alt>;
	 pinctrl-names = "default", "sleep";
 };
 
 &pinctrl {
	spi1_default_alt: spi1_default_alt {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 6)>,
			<NRF_PSEL(SPIM_MOSI, 0, 7)>,
			<NRF_PSEL(SPIM_MISO, 0, 25)>;
		};
 
	};

	spi1_sleep_alt: spi1_sleep_alt {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 6)>,
				<NRF_PSEL(SPIM_MOSI, 0, 7)>,
				<NRF_PSEL(SPIM_MISO, 0, 25)>;
			low-power-enable;
		};
	};
	spi4_default: spi4_default { 
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
				<NRF_PSEL(SPIM_MISO, 1, 14)>,			
				<NRF_PSEL(SPIM_MOSI, 1, 11)>;
				bias-pull-down;
		};
	};
	spi4_sleep: spi4_sleep { 
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
				<NRF_PSEL(SPIM_MOSI, 1, 11)>,
				<NRF_PSEL(SPIM_MISO, 1, 14)>;
			low-power-enable;
			bias-pull-down;
		};
	};
 
	//  spi2_default: spi2_default {
	// 	 group1 {
	// 		 psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
	// 				 <NRF_PSEL(SPIM_MOSI, 1, 2)>,
	// 				 <NRF_PSEL(SPIM_MISO, 1, 3)>;
	// 	 };
	//  };
 
	//  spi2_sleep: spi2_sleep {
	// 	 group1 {
	// 		 psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
	// 				 <NRF_PSEL(SPIM_MOSI, 1, 2)>,
	// 				 <NRF_PSEL(SPIM_MISO, 1, 3)>;
	// 		 low-power-enable;
	// 	 };
	//  };
		// 	 spi3_default: spi3_default {
		// 	 phandle = < 0x16 >;
		// 	 group1 {
		// 		 psels = < 0x4002f >, < 0x6002e >, < 0x5002d >;
		// 	 };
		//  };
		//  spi3_sleep: spi3_sleep {
		// 	 phandle = < 0x17 >;
		// 	 group1 {
		// 		 psels = < 0x4002f >, < 0x6002e >, < 0x5002d >;
		// 		 low-power-enable;
		// 	 };
		//  };
	 pwm0_default_alt: pwm0_default_alt {
		 group1 {
			 psels = <NRF_PSEL(PWM_OUT1, 0, 14)>;
			 nordic,invert;
		 };
	 };
 
	 pwm0_sleep_alt: pwm0_sleep_alt {
		 group1 {
			 psels = <NRF_PSEL(PWM_OUT1, 0, 14)>;
			 low-power-enable;
		 };
	 };
 
 };
 
 my_spi_master: &spi1 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	pinctrl-0 = <&spi1_default_alt>;
	pinctrl-1 = <&spi1_sleep_alt>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;
	reg_my_spi_master: spi-dev-a@0 {
		reg = <0>;
	};
};

 my_spi_master2: &spi4 {
	 compatible = "nordic,nrf-spim";
	 status = "okay";
	 pinctrl-0 = <&spi4_default>;
	 pinctrl-1 = <&spi4_sleep>; 
	 pinctrl-names = "default", "sleep";
	 cs-gpios = <&gpio0 27 GPIO_ACTIVE_LOW>;
 
  
 };