1/*
2 * Copyright (c) 2021 Guðni Már Gilbert
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/l4/stm32l412XB.dtsi>
9#include <st/l4/stm32l412rbtx-pinctrl.dtsi>
10#include "arduino_r3_connector.dtsi"
11#include <zephyr/dt-bindings/input/input-event-codes.h>
12
13/ {
14	model = "STMicroelectronics STM32L412RB-P-NUCLEO board";
15	compatible = "st,stm32l412rb-p-nucleo";
16
17	chosen {
18		zephyr,console = &lpuart1;
19		zephyr,shell-uart = &lpuart1;
20		zephyr,sram = &sram0;
21		zephyr,flash = &flash0;
22	};
23
24	leds: leds {
25		compatible = "gpio-leds";
26		green_led: led_0 {
27			gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
28			label = "User LD4";
29		};
30	};
31
32	gpio_keys {
33		compatible = "gpio-keys";
34		user_button: button {
35			label = "User";
36			gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
37			zephyr,code = <INPUT_KEY_0>;
38		};
39	};
40
41	aliases {
42		led0 = &green_led;
43		sw0 = &user_button;
44		volt-sensor0 = &vref;
45		volt-sensor1 = &vbat;
46	};
47};
48
49&clk_lsi {
50	status = "okay";
51};
52
53&clk_hsi {
54	status = "okay";
55};
56
57&pll {
58	div-m = <1>;
59	mul-n = <10>;
60	div-q = <2>;
61	div-r = <2>;
62	clocks = <&clk_hsi>;
63	status = "okay";
64};
65
66&rcc {
67	clocks = <&pll>;
68	clock-frequency = <DT_FREQ_M(80)>;
69	ahb-prescaler = <1>;
70	apb1-prescaler = <1>;
71	apb2-prescaler = <1>;
72};
73
74&lpuart1 {
75	pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
76	pinctrl-names = "default";
77	current-speed = <115200>;
78	status = "okay";
79};
80
81&usart1 {
82	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
83	pinctrl-names = "default";
84	current-speed = <115200>;
85};
86
87&spi2 {
88	pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>;
89	pinctrl-names = "default";
90	cs-gpios = <&gpioa 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
91	status = "okay";
92};
93
94&i2c1 {
95	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb7>;
96	pinctrl-names = "default";
97	clock-frequency = <I2C_BITRATE_FAST>;
98	status = "okay";
99};
100
101&timers2 {
102	status = "okay";
103
104	pwm2: pwm {
105		status = "okay";
106		pinctrl-0 = <&tim2_ch1_pa0>;
107		pinctrl-names = "default";
108	};
109};
110
111&rtc {
112	clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>,
113		 <&rcc STM32_SRC_LSI RTC_SEL(2)>;
114	status = "okay";
115};
116
117&adc1 {
118	pinctrl-0 = <&adc1_in5_pa0>;
119	pinctrl-names = "default";
120	st,adc-clock-source = "SYNC";
121	st,adc-prescaler = <4>;
122	status = "okay";
123};
124
125&flash0 {
126	partitions {
127		compatible = "fixed-partitions";
128		#address-cells = <1>;
129		#size-cells = <1>;
130
131		/*
132		 * Reserve the final 16 KiB for file system partition
133		 * 128 KiB --> 131702 bytes
134		 * 16 KiB  --> 16384 bytes
135		 * Start Addr = 131702 - 16384 --> (HEX) 0x0001c276
136		 * Size = 16384 --> (HEX) 0x00004000
137		 */
138		storage_partition: partition@1c276 {
139			label = "storage";
140			reg = <0x0001c276 DT_SIZE_K(16)>;
141		};
142	};
143};
144
145&vref {
146	status = "okay";
147};
148
149&vbat {
150	status = "okay";
151};
152