Skip to content

Commit

Permalink
tests: drivers: adc: adc_api: Move compat atmel,sam0-adc to DT
Browse files Browse the repository at this point in the history
Move channel description to devicetree for atmel,sam0-adc
compatible to make the test more readable.

Signed-off-by: Benjamin Björnsson <[email protected]>
  • Loading branch information
benjaminbjornsson authored and carlescufi committed Apr 14, 2023
1 parent 9024ffa commit 89ed720
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 10 deletions.
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/adafruit_trinket_m0.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/arduino_mkrzero.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/arduino_nano_33_iot.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/arduino_zero.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsamc21n_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc0 0>;
};
};

&adc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsamd21_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsame54_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1AU

/ {
zephyr,user {
io-channels = <&adc0 0>;
};
};

&adc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsaml21_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsamr21_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/atsamr34_xpro.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/serpente.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1BU

/ {
zephyr,user {
io-channels = <&adc 0>;
};
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
29 changes: 29 additions & 0 deletions tests/drivers/adc/adc_api/boards/wio_terminal.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Benjamin Björnsson <[email protected]>
*/

#include <zephyr/dt-bindings/adc/adc.h>

#define ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val 0x1AU

/ {
zephyr,user {
io-channels = <&adc0 0>;
};
};

&adc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val>;
};
};
10 changes: 0 additions & 10 deletions tests/drivers/adc/adc_api/src/test_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
#define ADC_1ST_CHANNEL_ID 0

#elif defined(CONFIG_SOC_FAMILY_SAM0)
#include <soc.h>
#define ADC_DEVICE_NODE DT_INST(0, atmel_sam0_adc)
#define ADC_RESOLUTION 12
#define ADC_GAIN ADC_GAIN_1
#define ADC_REFERENCE ADC_REF_INTERNAL
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
#define ADC_1ST_CHANNEL_ID 0
#define ADC_1ST_CHANNEL_INPUT ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC_Val

#endif

/* Invalid value that is not supposed to be written by the driver. It is used
Expand Down

0 comments on commit 89ed720

Please sign in to comment.