1 /*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/ztest.h>
8 #include <zephyr/device.h>
9 #include <zephyr/drivers/i2c.h>
10
11 #if DT_NODE_HAS_STATUS(DT_ALIAS(i2c_channel_0), okay)
12 #define I2C_0_CTRL_NODE_ID DT_ALIAS(i2c_channel_0)
13 #else
14 #error "I2C 0 controller device not found"
15 #endif
16
17 #if DT_NODE_HAS_STATUS(DT_ALIAS(i2c_channel_1), okay)
18 #define I2C_1_CTRL_NODE_ID DT_ALIAS(i2c_channel_1)
19 #else
20 #error "I2C 1 controller device not found"
21 #endif
22
23
24
25
26 /**
27 * @brief Test Asserts
28 *
29 * This test verifies various assert macros provided by ztest.
30 *
31 */
ZTEST(i2c_tca954x,test_tca954x)32 ZTEST(i2c_tca954x, test_tca954x)
33 {
34 uint8_t buff[1];
35
36 const struct device *const i2c0 = DEVICE_DT_GET(I2C_0_CTRL_NODE_ID);
37 const struct device *const i2c1 = DEVICE_DT_GET(I2C_1_CTRL_NODE_ID);
38
39 zassert_true(device_is_ready(i2c0), "I2C 0 not ready");
40 zassert_true(device_is_ready(i2c1), "I2C 1 not ready");
41
42 i2c_read(i2c0, buff, 1, 0x42);
43 i2c_read(i2c1, buff, 1, 0x42);
44 }
45
46 ZTEST_SUITE(i2c_tca954x, NULL, NULL, NULL, NULL, NULL);
47