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
27		green_led: led_0 {
28			gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
29			label = "User LD4";
30		};
31	};
32
33	gpio_keys {
34		compatible = "gpio-keys";
35
36		user_button: button {
37			label = "User";
38			gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
39			zephyr,code = <INPUT_KEY_0>;
40		};
41	};
42
43	aliases {
44		led0 = &green_led;
45		sw0 = &user_button;
46		volt-sensor0 = &vref;
47		volt-sensor1 = &vbat;
48	};
49};
50
51&clk_lsi {
52	status = "okay";
53};
54
55&clk_hsi {
56	status = "okay";
57};
58
59&pll {
60	div-m = <1>;
61	mul-n = <10>;
62	div-q = <2>;
63	div-r = <2>;
64	clocks = <&clk_hsi>;
65	status = "okay";
66};
67
68&rcc {
69	clocks = <&pll>;
70	clock-frequency = <DT_FREQ_M(80)>;
71	ahb-prescaler = <1>;
72	apb1-prescaler = <1>;
73	apb2-prescaler = <1>;
74};
75
76&lpuart1 {
77	pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
78	pinctrl-names = "default";
79	current-speed = <115200>;
80	status = "okay";
81};
82
83&usart1 {
84	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
85	pinctrl-names = "default";
86	current-speed = <115200>;
87};
88
89&spi2 {
90	pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>;
91	pinctrl-names = "default";
92	cs-gpios = <&gpioa 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
93	status = "okay";
94};
95
96&i2c1 {
97	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb7>;
98	pinctrl-names = "default";
99	clock-frequency = <I2C_BITRATE_FAST>;
100	status = "okay";
101};
102
103&timers2 {
104	status = "okay";
105
106	pwm2: pwm {
107		status = "okay";
108		pinctrl-0 = <&tim2_ch1_pa0>;
109		pinctrl-names = "default";
110	};
111};
112
113&rtc {
114	clocks = <&rcc STM32_CLOCK(APB1, 28)>,
115		 <&rcc STM32_SRC_LSI RTC_SEL(2)>;
116	status = "okay";
117};
118
119&adc1 {
120	pinctrl-0 = <&adc1_in5_pa0>;
121	pinctrl-names = "default";
122	st,adc-clock-source = "SYNC";
123	st,adc-prescaler = <4>;
124	status = "okay";
125};
126
127&flash0 {
128	partitions {
129		compatible = "fixed-partitions";
130		#address-cells = <1>;
131		#size-cells = <1>;
132
133		/*
134		 * Reserve the final 16 KiB for file system partition
135		 * 128 KiB --> 131702 bytes
136		 * 16 KiB  --> 16384 bytes
137		 * Start Addr = 131702 - 16384 --> (HEX) 0x0001c276
138		 * Size = 16384 --> (HEX) 0x00004000
139		 */
140		storage_partition: partition@1c276 {
141			label = "storage";
142			reg = <0x0001c276 DT_SIZE_K(16)>;
143		};
144	};
145};
146
147&vref {
148	status = "okay";
149};
150
151&vbat {
152	status = "okay";
153};
154