Skip to content

Commit 7f3c08b

Browse files
nordic-bamicarlescufi
authored andcommitted
tests: drivers: Allow configurable i2c speed for bme688 test
Configure the I2C test speed with K-config Signed-off-by: Bartosz Miller <[email protected]>
1 parent 8538c4a commit 7f3c08b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tests/drivers/i2c/i2c_bme688/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# I2C BME688 test configuration options
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config TEST_I2C_SPEED
6+
int "Select I2C speed used during the test, selectable options are: I2C_SPEED_STANDARD (0x1U), I2C_SPEED_FAST (0x2U), I2C_SPEED_FAST_PLUS (0x3U)"
7+
default 1
8+
9+
source "Kconfig.zephyr"

tests/drivers/i2c/i2c_bme688/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ static uint16_t read_adc_humidity(void)
201201
ZTEST(i2c_controller_to_sensor, test_i2c_basic_memory_read)
202202
{
203203
int err;
204-
uint32_t i2c_config = I2C_SPEED_SET(I2C_SPEED_FAST) | I2C_MODE_CONTROLLER;
204+
uint32_t i2c_config = I2C_SPEED_SET(CONFIG_TEST_I2C_SPEED) | I2C_MODE_CONTROLLER;
205205
uint8_t entire_sensor_memory[SENSOR_MEMORY_SIZE_IN_BYTES] = {0};
206206

207207
TC_PRINT("Device address 0x%x\n", DEVICE_ADDRESS);
208+
TC_PRINT("I2C speed setting: %d\n", CONFIG_TEST_I2C_SPEED);
208209

209210
err = i2c_configure(i2c_device, i2c_config);
210211
zassert_equal(err, 0, "i2c_configure' failed with error: %d\n", err);
@@ -250,10 +251,11 @@ ZTEST(i2c_controller_to_sensor, test_i2c_controlled_sensor_operation)
250251
int16_t temperature = 0;
251252
uint32_t pressure = 0;
252253
uint32_t humidity = 0;
253-
uint32_t i2c_config = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_CONTROLLER;
254+
uint32_t i2c_config = I2C_SPEED_SET(CONFIG_TEST_I2C_SPEED) | I2C_MODE_CONTROLLER;
254255
uint8_t measurements_left = MEASUREMENT_CYCLES + 1;
255256

256257
TC_PRINT("Device address 0x%x\n", DEVICE_ADDRESS);
258+
TC_PRINT("I2C speed setting: %d\n", CONFIG_TEST_I2C_SPEED);
257259

258260
err = i2c_configure(i2c_device, i2c_config);
259261
zassert_equal(err, 0, "i2c_configure' failed with error: %d\n", err);

0 commit comments

Comments
 (0)