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:
parent
ddb1971fe3
commit
7eb075ef2b
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
14
tests/drivers/w1/w1_api/ds2484.overlay
Normal file
14
tests/drivers/w1/w1_api/ds2484.overlay
Normal 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"
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
description: 1-Wire dummy slave
|
||||
|
||||
compatible: "test-w1-dummy-slave"
|
||||
compatible: "vnd,w1-device"
|
||||
|
||||
include: w1-slave.yaml
|
1
tests/drivers/w1/w1_api/i2c.conf
Normal file
1
tests/drivers/w1/w1_api/i2c.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_I2C=y
|
1
tests/drivers/w1/w1_api/serial.conf
Normal file
1
tests/drivers/w1/w1_api/serial.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_SERIAL=y
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
20
tests/drivers/w1/w1_api/w1_devices.dtsi
Normal file
20
tests/drivers/w1/w1_api/w1_devices.dtsi
Normal 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";
|
||||
};
|
||||
};
|
13
tests/drivers/w1/w1_api/w1_serial.overlay
Normal file
13
tests/drivers/w1/w1_api/w1_serial.overlay
Normal 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"
|
Loading…
Reference in a new issue