Skip to content

Commit c72b75f

Browse files
soburiMaureenHelm
authored andcommitted
boards: riscv: longan_nano: Add LED and button configuration
Add configuration to support onboard LED and button. - LED_R: PC13 (active low/output) - LED_G: PA1 (active low/output) - LED_B: PA2 (active low/output) - BOOT0: PA8 (active high/input) And enable timer1 to control LED_G and LED_B with PWM. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 0cae1d8 commit c72b75f

File tree

4 files changed

+106
-40
lines changed

4 files changed

+106
-40
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (c) 2021 Tokita, Hiroshi <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,console = &usart0;
10+
zephyr,shell-uart = &usart0;
11+
zephyr,sram = &sram0;
12+
zephyr,flash = &flash0;
13+
};
14+
15+
leds {
16+
compatible = "gpio-leds";
17+
led_red: led_red {
18+
gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
19+
label = "LED_R";
20+
};
21+
led_green: led_green {
22+
gpios = <&gpioa 1 GPIO_ACTIVE_LOW>;
23+
label = "LED_G";
24+
};
25+
led_blue: led_blue {
26+
gpios = <&gpioa 2 GPIO_ACTIVE_LOW>;
27+
label = "LED_B";
28+
};
29+
};
30+
31+
gpio_keys {
32+
compatible = "gpio-keys";
33+
button_boot0: button_boot0 {
34+
label = "BUTTON_BOOT0";
35+
gpios = <&gpioa 8 GPIO_ACTIVE_HIGH>;
36+
};
37+
};
38+
39+
pwmleds {
40+
compatible = "pwm-leds";
41+
42+
/* NOTE: bridge TIMER1_CH1 and LED_GREEN (PA1) */
43+
pwm_led_green: pwm_led_green {
44+
pwms = <&pwm1 1 PWM_POLARITY_NORMAL>;
45+
label = "PWM_LED_G";
46+
};
47+
/* NOTE: bridge TIMER1_CH2 and LED_BLUE (PA2) */
48+
pwm_led_blue: pwm_led_blue {
49+
pwms = <&pwm1 2 PWM_POLARITY_NORMAL>;
50+
label = "PWM_LED_B";
51+
};
52+
};
53+
54+
aliases {
55+
led0 = &led_red;
56+
led1 = &led_green;
57+
led2 = &led_blue;
58+
pwm-led0 = &pwm_led_green;
59+
pwm-led1 = &pwm_led_blue;
60+
sw0 = &button_boot0;
61+
};
62+
};
63+
64+
&gpioa {
65+
status = "okay";
66+
};
67+
68+
&gpiob {
69+
status = "okay";
70+
};
71+
72+
&gpioc {
73+
status = "okay";
74+
};
75+
76+
&usart0 {
77+
status = "okay";
78+
current-speed = <115200>;
79+
pinctrl-0 = <&usart0_default>;
80+
pinctrl-names = "default";
81+
};
82+
83+
&timer1 {
84+
status = "okay";
85+
prescaler = <4096>;
86+
87+
pwm1: pwm {
88+
status = "okay";
89+
pinctrl-0 = <&pwm1_default>;
90+
pinctrl-names = "default";
91+
};
92+
};
93+
94+
&dac {
95+
status = "okay";
96+
pinctrl-0 = <&dac_default>;
97+
pinctrl-names = "default";
98+
};

boards/riscv/longan_nano/longan_nano-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
};
1313
};
1414

15+
pwm1_default: pwm1_default {
16+
group1 {
17+
pinmux = <TIMER1_CH1_PA1_OUT_NORMP>, <TIMER1_CH2_PA2_OUT_NORMP>;
18+
};
19+
};
20+
1521
dac_default: dac_default {
1622
group1 {
1723
pinmux = <DAC_OUT0_PA4>;

boards/riscv/longan_nano/longan_nano.dts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,9 @@
77
/dts-v1/;
88
#include <gigadevice/gd32vf103Xb.dtsi>
99
#include "longan_nano-pinctrl.dtsi"
10+
#include "longan_nano-common.dtsi"
1011

1112
/ {
1213
model = "Sipeed Longan Nano";
1314
compatible = "sipeed,longan_nano";
14-
15-
chosen {
16-
zephyr,console = &usart0;
17-
zephyr,shell-uart = &usart0;
18-
zephyr,sram = &sram0;
19-
zephyr,flash = &flash0;
20-
};
21-
};
22-
23-
&usart0 {
24-
status = "okay";
25-
current-speed = <115200>;
26-
pinctrl-0 = <&usart0_default>;
27-
pinctrl-names = "default";
28-
};
29-
30-
&dac {
31-
status = "okay";
32-
pinctrl-0 = <&dac_default>;
33-
pinctrl-names = "default";
3415
};

boards/riscv/longan_nano/longan_nano_lite.dts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,9 @@
77
/dts-v1/;
88
#include <gigadevice/gd32vf103X8.dtsi>
99
#include "longan_nano-pinctrl.dtsi"
10+
#include "longan_nano-common.dtsi"
1011

1112
/ {
1213
model = "Sipeed Longan Nano Lite";
1314
compatible = "sipeed,longan_nano_lite";
14-
15-
chosen {
16-
zephyr,console = &usart0;
17-
zephyr,shell-uart = &usart0;
18-
zephyr,sram = &sram0;
19-
zephyr,flash = &flash0;
20-
};
21-
};
22-
23-
&usart0 {
24-
status = "okay";
25-
current-speed = <115200>;
26-
pinctrl-0 = <&usart0_default>;
27-
pinctrl-names = "default";
28-
};
29-
30-
&dac {
31-
status = "okay";
32-
pinctrl-0 = <&dac_default>;
33-
pinctrl-names = "default";
3415
};

0 commit comments

Comments
 (0)