tests: w1: api: Add DS2484 as possible bus master for 1-Wire API tests

Also:
- Restructure test to have different bus master present

Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
This commit is contained in:
Caspar Friedrich 2022-07-19 22:22:14 +02:00 committed by Carles Cufí
parent ddb1971fe3
commit 7eb075ef2b
12 changed files with 69 additions and 53 deletions

View file

@ -4,8 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "serial_overlay.dtsi"
/* external connection of TX-pin to RX-pin needed */
&pinctrl {
uart1_default: uart1_default {

View file

@ -4,8 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "serial_overlay.dtsi"
&usart1_tx_pc4 {
/*
* enable open-drain drive such that no external push-pull to

View file

@ -1,29 +0,0 @@
/*
* Copyright (c) 2022 Thomas Stranger
*
* SPDX-License-Identifier: Apache-2.0
*/
&arduino_serial {
status = "okay";
w1-zephyr-serial-0 {
compatible = "zephyr,w1-serial";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
slave_1: dummy-slave-1 {
compatible = "test-w1-dummy-slave";
family-code = <0x28>;
overdrive-speed;
status = "okay";
};
slave_2: dummy-slave-2 {
compatible = "test-w1-dummy-slave";
family-code = <0x29>;
status = "okay";
};
};
};

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2022 Caspar Friedrich <c.s.w.friedrich@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
&arduino_i2c {
w1_0: w1@18 {
compatible = "maxim,ds2484";
reg = <0x18>;
};
};
#include "w1_devices.dtsi"

View file

@ -3,6 +3,6 @@
description: 1-Wire dummy slave
compatible: "test-w1-dummy-slave"
compatible: "vnd,w1-device"
include: w1-slave.yaml

View file

@ -0,0 +1 @@
CONFIG_I2C=y

View file

@ -0,0 +1 @@
CONFIG_SERIAL=y

View file

@ -4,23 +4,16 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <ztest.h>
#include <zephyr/drivers/w1.h>
#include <zephyr/zephyr.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/drivers/sensor/w1_sensor.h>
#include <zephyr/drivers/w1.h>
#include <zephyr/zephyr.h>
#include <zephyr/ztest.h>
#define W1_MASTER DT_NODELABEL(w1_0)
#define W1_SLAVE_1 DT_NODELABEL(slave_1)
#define W1_SLAVE_2 DT_NODELABEL(slave_2)
#define ZEPHYR_W1_SERIAL DT_INST(0, zephyr_w1_serial)
#if DT_NODE_HAS_STATUS(ZEPHYR_W1_SERIAL, okay)
#define W1_MASTER ZEPHYR_W1_SERIAL
#else
#error Your devicetree has no enabled nodes with a compatible w1-driver
#endif
const struct device *get_w1_master_dev(void)
{
const struct device *master_dev = DEVICE_DT_GET(W1_MASTER);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT test_w1_dummy_slave
#define DT_DRV_COMPAT vnd_w1_device
#include <zephyr/device.h>
#include <zephyr/drivers/w1.h>
@ -19,9 +19,8 @@ static int w1_dummy_slave_init(const struct device *dev)
return 0;
}
#define TEST_W1_DUMMY_SLAVE_DEFINE(inst) \
DEVICE_DT_INST_DEFINE(inst, w1_dummy_slave_init, NULL, NULL, NULL, \
POST_KERNEL, CONFIG_W1_INIT_PRIORITY, \
&w1_dummy_slave_api1);
#define TEST_W1_DUMMY_SLAVE_DEFINE(inst) \
DEVICE_DT_INST_DEFINE(inst, w1_dummy_slave_init, NULL, NULL, NULL, POST_KERNEL, \
CONFIG_W1_INIT_PRIORITY, &w1_dummy_slave_api1);
DT_INST_FOREACH_STATUS_OKAY(TEST_W1_DUMMY_SLAVE_DEFINE)

View file

@ -1,9 +1,17 @@
common:
tags: drivers w1 userspace
harness: ztest
harness_config:
fixture: w1_serial_idle
tests:
drivers.w1.w1-serial:
filter: dt_compat_enabled("zephyr,w1-serial")
depends_on: arduino_serial
extra_args: DTC_OVERLAY_FILE=w1_serial.overlay OVERLAY_CONFIG=serial.conf
platform_allow: nucleo_g0b1re nrf52840dk_nrf52840
harness_config:
fixture: w1_serial_idle
drivers.w1.ds2484:
depends_on: arduino_i2c
extra_args: DTC_OVERLAY_FILE=ds2484.overlay OVERLAY_CONFIG=i2c.conf
platform_allow: nrf52840dk_nrf52840
harness_config:
fixture: w1_ds2484_idle

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Thomas Stranger
*
* SPDX-License-Identifier: Apache-2.0
*/
&w1_0 {
slave_1: dummy-slave-1 {
compatible = "vnd,w1-device";
family-code = <0x28>;
overdrive-speed;
status = "okay";
};
slave_2: dummy-slave-2 {
compatible = "vnd,w1-device";
family-code = <0x29>;
status = "okay";
};
};

View file

@ -0,0 +1,13 @@
/*
* Copyright (c) 2022 Caspar Friedrich <c.s.w.friedrich@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
&arduino_serial {
w1_0: w1 {
compatible = "zephyr,w1-serial";
};
};
#include "w1_devices.dtsi"