Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dts: riscv: gigadevice: Add GD32VF103 DAC configuration #41552

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/riscv/longan_nano/longan_nano-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
pinmux = <USART0_TX_PA9_NORMP>, <USART0_RX_PA10_NORMP>;
};
};

dac_default: dac_default {
group1 {
pinmux = <DAC_OUT0_PA4>;
};
};
};
6 changes: 6 additions & 0 deletions boards/riscv/longan_nano/longan_nano.dts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@
pinctrl-0 = <&usart0_default>;
pinctrl-names = "default";
};

&dac {
status = "okay";
pinctrl-0 = <&dac_default>;
pinctrl-names = "default";
};
6 changes: 6 additions & 0 deletions boards/riscv/longan_nano/longan_nano_lite.dts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@
pinctrl-0 = <&usart0_default>;
pinctrl-names = "default";
};

&dac {
status = "okay";
pinctrl-0 = <&dac_default>;
pinctrl-names = "default";
};
2 changes: 1 addition & 1 deletion drivers/dac/Kconfig.gd32
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DT_COMPAT_GD_GD32_DAC := gd,gd32-dac

config DAC_GD32
bool "GD32 DAC driver"
depends on SOC_FAMILY_GD32
depends on (SOC_FAMILY_GD32 || SOC_SERIES_GD32VF103)
default $(dt_compat_enabled,$(DT_COMPAT_GD_GD32_DAC))
help
Enable GigaDevice GD32 DAC driver
10 changes: 10 additions & 0 deletions dts/riscv/gigadevice/gd32vf103.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
label = "UART_2";
};

dac: dac@40007400 {
compatible = "gd,gd32-dac";
reg = <0x40007400 0x400>;
rcu-periph-clock = <0x71d>;
num-channels = <2>;
label = "DAC";
status = "disabled";
#io-channel-cells = <1>;
};

afio: afio@40010000 {
compatible = "gd,gd32-afio";
reg = <0x40010000 0x400>;
Expand Down
20 changes: 20 additions & 0 deletions samples/drivers/dac/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ The sample can be built and executed for the

Bridge the JP23 to DAC with the jumper cap, then DAC output will available on JP7.

Building and Running for Longan Nano and Longan Nano Lite
=========================================================
The sample can be built and executed for the
:ref:`longan_nano` as follows:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/dac
:board: longan_nano
:goals: build flash
:compact:

also can run for the
:ref: `longan_nano_lite` as follows:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/dac
:board: longan_nano_lite
:goals: build flash
:compact:

Sample output
=============

Expand Down
13 changes: 13 additions & 0 deletions samples/drivers/dac/boards/longan_nano.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright 2021 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
dac = <&dac>;
dac-channel-id = <0>;
dac-resolution = <12>;
};
};
13 changes: 13 additions & 0 deletions samples/drivers/dac/boards/longan_nano_lite.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright 2021 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
dac = <&dac>;
dac-channel-id = <0>;
dac-resolution = <12>;
};
};
2 changes: 1 addition & 1 deletion samples/drivers/dac/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tests:
arduino_zero frdm_k22f frdm_k64f nucleo_f091rc nucleo_g071rb nucleo_g431rb
nucleo_l073rz nucleo_l152re twr_ke18f nucleo_f767zi nucleo_f429zi bl652_dvk
bl653_dvk bl654_dvk bl5340_dvk_cpuapp stm32f3_disco stm32l562e_dk nucleo_l552ze_q
gd32f450i_eval
gd32f450i_eval longan_nano longan_nano_lite
depends_on: dac
harness: console
harness_config:
Expand Down