diff options
-rw-r--r-- | common/i2c_controller.c | 9 | ||||
-rw-r--r-- | zephyr/test/drivers/src/bb_retimer.c | 13 | ||||
-rw-r--r-- | zephyr/test/drivers/src/bma2x2.c | 70 | ||||
-rw-r--r-- | zephyr/test/drivers/src/bmi160.c | 123 | ||||
-rw-r--r-- | zephyr/test/drivers/src/bmi260.c | 131 | ||||
-rw-r--r-- | zephyr/test/drivers/src/tcs3400.c | 20 |
6 files changed, 217 insertions, 149 deletions
diff --git a/common/i2c_controller.c b/common/i2c_controller.c index dfc3417e88..fabb0e34f3 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -266,7 +266,14 @@ int i2c_xfer_unlocked(const int port, in, in_size); } - return ret; + switch (ret) { + case 0: + return EC_SUCCESS; + case -EIO: + return EC_ERROR_INVAL; + default: + return EC_ERROR_UNKNOWN; + } #elif defined(CONFIG_I2C_XFER_LARGE_TRANSFER) ret = i2c_xfer_no_retry(port, no_pec_af, out, out_size, in, diff --git a/zephyr/test/drivers/src/bb_retimer.c b/zephyr/test/drivers/src/bb_retimer.c index eb48fb0789..cecee6020f 100644 --- a/zephyr/test/drivers/src/bb_retimer.c +++ b/zephyr/test/drivers/src/bb_retimer.c @@ -53,8 +53,9 @@ static void test_bb_set_state(void) BB_RETIMER_REG_CONNECTION_STATE); /* Test fail on reset register write */ - zassert_equal(-EIO, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1], - USB_PD_MUX_NONE, &ack_required), + zassert_equal(EC_ERROR_INVAL, + bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1], + USB_PD_MUX_NONE, &ack_required), NULL); zassert_false(ack_required, "ACK is never required for BB retimer"); @@ -446,8 +447,8 @@ static void test_bb_init(void) /* Setup emulator fail on read */ i2c_common_emul_set_read_fail_reg(emul, BB_RETIMER_REG_VENDOR_ID); /* Test fail on vendor ID read */ - zassert_equal(-EIO, bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), - NULL); + zassert_equal(EC_ERROR_INVAL, + bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL); /* Enable pins should be set always after init, when AP is on */ zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT), NULL); @@ -471,8 +472,8 @@ static void test_bb_init(void) i2c_common_emul_set_read_fail_reg(emul, BB_RETIMER_REG_DEVICE_ID); bb_emul_set_reg(emul, BB_RETIMER_REG_VENDOR_ID, BB_RETIMER_VENDOR_ID_1); /* Test fail on device ID read */ - zassert_equal(-EIO, bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), - NULL); + zassert_equal(EC_ERROR_INVAL, + bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL); zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT), NULL); zassert_equal(1, gpio_emul_output_get(gpio_dev, diff --git a/zephyr/test/drivers/src/bma2x2.c b/zephyr/test/drivers/src/bma2x2.c index f655e0c99a..8b77464b48 100644 --- a/zephyr/test/drivers/src/bma2x2.c +++ b/zephyr/test/drivers/src/bma2x2.c @@ -165,11 +165,14 @@ static void test_bma_get_offset(void) /* Test fail on each axis */ i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_X_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->get_offset(&ms, ret_offset, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, + ms.drv->get_offset(&ms, ret_offset, &temp), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_Y_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->get_offset(&ms, ret_offset, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, + ms.drv->get_offset(&ms, ret_offset, &temp), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_Z_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->get_offset(&ms, ret_offset, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, + ms.drv->get_offset(&ms, ret_offset, &temp), NULL); /* Do not fail on read */ i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -213,11 +216,14 @@ static void test_bma_set_offset(void) /* Test fail on each axis */ i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_X_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->set_offset(&ms, exp_offset, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_Y_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->set_offset(&ms, exp_offset, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_Z_AXIS_ADDR); - zassert_equal(-EIO, ms.drv->set_offset(&ms, exp_offset, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp), + NULL); /* Do not fail on write */ i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -311,11 +317,11 @@ static void test_bma_set_range(void) i2c_common_emul_set_read_fail_reg(emul, BMA2x2_RANGE_SELECT_ADDR); /* Test fail on read */ - zassert_equal(-EIO, ms.drv->set_range(&ms, 12, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 0), NULL); zassert_equal(start_range, ms.current_range, NULL); zassert_equal(BMA2x2_RANGE_2G, bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL); - zassert_equal(-EIO, ms.drv->set_range(&ms, 12, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 1), NULL); zassert_equal(start_range, ms.current_range, NULL); zassert_equal(BMA2x2_RANGE_2G, bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL); @@ -327,11 +333,11 @@ static void test_bma_set_range(void) i2c_common_emul_set_write_fail_reg(emul, BMA2x2_RANGE_SELECT_ADDR); /* Test fail on write */ - zassert_equal(-EIO, ms.drv->set_range(&ms, 12, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 0), NULL); zassert_equal(start_range, ms.current_range, NULL); zassert_equal(BMA2x2_RANGE_2G, bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL); - zassert_equal(-EIO, ms.drv->set_range(&ms, 12, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 1), NULL); zassert_equal(start_range, ms.current_range, NULL); zassert_equal(BMA2x2_RANGE_2G, bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL); @@ -394,7 +400,7 @@ static void test_bma_init(void) bma_emul_set_reg(emul, BMA2x2_CHIP_ID_ADDR, BMA255_CHIP_ID_MAJOR); /* Test fail on reset register read */ - zassert_equal(-EIO, ms.drv->init(&ms), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->init(&ms), NULL); /* Do not fail on read */ i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -403,7 +409,7 @@ static void test_bma_init(void) i2c_common_emul_set_write_fail_reg(emul, BMA2x2_RST_ADDR); /* Test fail on reset register write */ - zassert_equal(-EIO, ms.drv->init(&ms), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->init(&ms), NULL); /* Do not fail on write */ i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -574,11 +580,13 @@ static void test_bma_rate(void) i2c_common_emul_set_read_fail_reg(emul, BMA2x2_BW_SELECT_ADDR); /* Test fail on read */ - zassert_equal(-EIO, ms.drv->set_data_rate(&ms, 15625, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 0), + NULL); zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL); - zassert_equal(reg_rate, - bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), NULL); - zassert_equal(-EIO, ms.drv->set_data_rate(&ms, 15625, 1), NULL); + zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), + NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 1), + NULL); zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL); zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), NULL); @@ -590,14 +598,16 @@ static void test_bma_rate(void) i2c_common_emul_set_write_fail_reg(emul, BMA2x2_BW_SELECT_ADDR); /* Test fail on write */ - zassert_equal(-EIO, ms.drv->set_data_rate(&ms, 15625, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 0), + NULL); zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL); - zassert_equal(reg_rate, - bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), NULL); - zassert_equal(-EIO, ms.drv->set_data_rate(&ms, 15625, 1), NULL); + zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), + NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 1), + NULL); zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL); - zassert_equal(reg_rate, - bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), NULL); + zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), + NULL); /* Do not fail on write */ i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -620,17 +630,17 @@ static void test_bma_read(void) /* Test fail on each axis */ i2c_common_emul_set_read_fail_reg(emul, BMA2x2_X_AXIS_LSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_X_AXIS_MSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Y_AXIS_LSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Y_AXIS_MSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Z_AXIS_LSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Z_AXIS_MSB_ADDR); - zassert_equal(-EIO, ms.drv->read(&ms, ret_acc_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL); /* Do not fail on read */ i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -803,7 +813,7 @@ static void test_bma_perform_calib(void) zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL); /* Test fail on first access to offset control register */ - zassert_equal(-EIO, ms.drv->perform_calib(&ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->perform_calib(&ms, 1), NULL); zassert_equal(range, ms.current_range, NULL); zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL); @@ -827,7 +837,7 @@ static void test_bma_perform_calib(void) func_data.time = 160; /* Test fail on read during offset compensation */ - zassert_equal(-EIO, ms.drv->perform_calib(&ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms.drv->perform_calib(&ms, 1), NULL); zassert_equal(range, ms.current_range, NULL); zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL); diff --git a/zephyr/test/drivers/src/bmi160.c b/zephyr/test/drivers/src/bmi160.c index 030325674b..ceb55896eb 100644 --- a/zephyr/test/drivers/src/bmi160.c +++ b/zephyr/test/drivers/src/bmi160.c @@ -156,11 +156,14 @@ static void test_bmi_acc_get_offset(void) /* Test fail on offset read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 1); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 2); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Disable rotation */ @@ -213,13 +216,17 @@ static void test_bmi_gyr_get_offset(void) /* Test fail on offset read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 1); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 2); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Disable rotation */ @@ -262,19 +269,24 @@ static void test_bmi_acc_set_offset(void) /* Test fail on OFFSET EN GYR98 register read and write */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test fail on offset write */ i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 1); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 2); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Set input offset */ @@ -333,19 +345,24 @@ static void test_bmi_gyr_set_offset(void) /* Test fail on OFFSET EN GYR98 register read and write */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test fail on offset write */ i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70 + 1); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70 + 2); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Set input offset */ @@ -445,11 +462,11 @@ static void test_bmi_acc_set_range(void) i2c_common_emul_set_write_fail_reg(emul, BMI160_ACC_RANGE); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_range(ms, 12, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 0), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI160_GSEL_2G, bmi_emul_get_reg(emul, BMI160_ACC_RANGE), NULL); - zassert_equal(-EIO, ms->drv->set_range(ms, 12, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 1), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI160_GSEL_2G, bmi_emul_get_reg(emul, BMI160_ACC_RANGE), NULL); @@ -553,11 +570,11 @@ static void test_bmi_gyr_set_range(void) i2c_common_emul_set_write_fail_reg(emul, BMI160_GYR_RANGE); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_range(ms, 125, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 0), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI160_DPS_SEL_250, bmi_emul_get_reg(emul, BMI160_GYR_RANGE), NULL); - zassert_equal(-EIO, ms->drv->set_range(ms, 125, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 1), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI160_DPS_SEL_250, bmi_emul_get_reg(emul, BMI160_GYR_RANGE), NULL); @@ -760,10 +777,12 @@ static void test_bmi_acc_rate(void) i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_CONF); /* Test fail on read */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL); @@ -774,10 +793,12 @@ static void test_bmi_acc_rate(void) i2c_common_emul_set_write_fail_reg(emul, BMI160_ACC_CONF); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL); @@ -939,10 +960,12 @@ static void test_bmi_gyr_rate(void) i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_CONF); /* Test fail on read */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL); @@ -953,10 +976,12 @@ static void test_bmi_gyr_rate(void) i2c_common_emul_set_write_fail_reg(emul, BMI160_GYR_CONF); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL); @@ -1118,7 +1143,7 @@ static void test_bmi_acc_read(void) /* Fail on read status */ i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -1189,17 +1214,17 @@ static void test_bmi_acc_read(void) /* Fail on read of data registers */ i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_X_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_X_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Y_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Y_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Z_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Z_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); ms->rot_standard_ref = NULL; @@ -1226,7 +1251,7 @@ static void test_bmi_gyr_read(void) /* Fail on read status */ i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -1297,17 +1322,17 @@ static void test_bmi_gyr_read(void) /* Fail on read of data registers */ i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_X_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_X_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Y_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Y_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Z_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Z_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); ms->rot_standard_ref = NULL; @@ -1383,13 +1408,13 @@ static void test_bmi_acc_perform_calib(void) /* Test fail on rate set */ i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_CONF); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on status read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Stop fast offset compensation before next test */ @@ -1507,13 +1532,13 @@ static void test_bmi_gyr_perform_calib(void) /* Test fail on rate set */ i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_CONF); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on status read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Stop fast offset compensation before next test */ @@ -1708,9 +1733,9 @@ static void test_bmi_acc_fifo(void) /* Test fail to read interrupt status registers */ i2c_common_emul_set_read_fail_reg(emul, BMI160_INT_STATUS_0); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_INT_STATUS_1); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test no interrupt */ diff --git a/zephyr/test/drivers/src/bmi260.c b/zephyr/test/drivers/src/bmi260.c index b4bd9b540a..637e5f353b 100644 --- a/zephyr/test/drivers/src/bmi260.c +++ b/zephyr/test/drivers/src/bmi260.c @@ -156,11 +156,14 @@ static void test_bmi_acc_get_offset(void) /* Test fail on offset read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 1); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 2); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Disable rotation */ @@ -213,13 +216,17 @@ static void test_bmi_gyr_get_offset(void) /* Test fail on offset read */ i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 1); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 2); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->get_offset(ms, ret, &temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Disable rotation */ @@ -263,19 +270,24 @@ static void test_bmi_acc_set_offset(void) /* Test fail on NV CONF register read and write */ i2c_common_emul_set_read_fail_reg(emul, BMI260_NV_CONF); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); i2c_common_emul_set_write_fail_reg(emul, BMI260_NV_CONF); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test fail on offset write */ i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 1); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 2); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Setup NV_CONF register value */ @@ -341,19 +353,24 @@ static void test_bmi_gyr_set_offset(void) /* Test fail on OFFSET EN GYR98 register read and write */ i2c_common_emul_set_read_fail_reg(emul, BMI260_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test fail on offset write */ i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70 + 1); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70 + 2); - zassert_equal(-EIO, ms->drv->set_offset(ms, input_v, temp), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp), + NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Set input offset */ @@ -457,11 +474,11 @@ static void test_bmi_acc_set_range(void) i2c_common_emul_set_write_fail_reg(emul, BMI260_ACC_RANGE); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_range(ms, 12, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 0), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI260_GSEL_2G, bmi_emul_get_reg(emul, BMI260_ACC_RANGE), NULL); - zassert_equal(-EIO, ms->drv->set_range(ms, 12, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 1), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI260_GSEL_2G, bmi_emul_get_reg(emul, BMI260_ACC_RANGE), NULL); @@ -565,11 +582,11 @@ static void test_bmi_gyr_set_range(void) i2c_common_emul_set_write_fail_reg(emul, BMI260_GYR_RANGE); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_range(ms, 125, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 0), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI260_DPS_SEL_250, bmi_emul_get_reg(emul, BMI260_GYR_RANGE), NULL); - zassert_equal(-EIO, ms->drv->set_range(ms, 125, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 1), NULL); zassert_equal(start_range, ms->current_range, NULL); zassert_equal(BMI260_DPS_SEL_250, bmi_emul_get_reg(emul, BMI260_GYR_RANGE), NULL); @@ -772,10 +789,12 @@ static void test_bmi_acc_rate(void) i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_CONF); /* Test fail on read */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL); @@ -786,10 +805,12 @@ static void test_bmi_acc_rate(void) i2c_common_emul_set_write_fail_reg(emul, BMI260_ACC_CONF); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL); @@ -952,10 +973,12 @@ static void test_bmi_gyr_rate(void) i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_CONF); /* Test fail on read */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL); @@ -966,10 +989,12 @@ static void test_bmi_gyr_rate(void) i2c_common_emul_set_write_fail_reg(emul, BMI260_GYR_CONF); /* Test fail on write */ - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 50000, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1), + NULL); zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL); zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL); @@ -1135,7 +1160,7 @@ static void test_bmi_acc_read(void) /* Fail on read status */ i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -1206,17 +1231,17 @@ static void test_bmi_acc_read(void) /* Fail on read of data registers */ i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Y_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Y_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Z_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Z_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); ms->rot_standard_ref = NULL; @@ -1243,7 +1268,7 @@ static void test_bmi_gyr_read(void) /* Fail on read status */ i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -1314,17 +1339,17 @@ static void test_bmi_gyr_read(void) /* Fail on read of data registers */ i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Y_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Y_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Z_L_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Z_H_G); - zassert_equal(-EIO, ms->drv->read(ms, ret_v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); ms->rot_standard_ref = NULL; @@ -1374,14 +1399,14 @@ static void test_bmi_acc_perform_calib(void) /* Test fail on rate read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_CONF); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on status read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); @@ -1397,13 +1422,13 @@ static void test_bmi_acc_perform_calib(void) /* Test fail on data read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_L_G); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on setting offset */ i2c_common_emul_set_read_fail_reg(emul, BMI260_NV_CONF); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); @@ -1465,14 +1490,14 @@ static void test_bmi_gyr_perform_calib(void) /* Test fail on rate read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_CONF); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on status read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); @@ -1492,13 +1517,13 @@ static void test_bmi_gyr_perform_calib(void) /* Test fail on data read */ i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_L_G); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); /* Test fail on setting offset */ i2c_common_emul_set_read_fail_reg(emul, BMI260_OFFSET_EN_GYR98); - zassert_equal(-EIO, ms->drv->perform_calib(ms, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL); zassert_equal(range, ms->current_range, NULL); zassert_equal(rate, ms->drv->get_data_rate(ms), NULL); @@ -1699,9 +1724,9 @@ static void test_bmi_acc_fifo(void) /* Test fail to read interrupt status registers */ i2c_common_emul_set_read_fail_reg(emul, BMI260_INT_STATUS_0); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_read_fail_reg(emul, BMI260_INT_STATUS_1); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test no interrupt */ diff --git a/zephyr/test/drivers/src/tcs3400.c b/zephyr/test/drivers/src/tcs3400.c index e1830b1775..c20137c1ad 100644 --- a/zephyr/test/drivers/src/tcs3400.c +++ b/zephyr/test/drivers/src/tcs3400.c @@ -39,7 +39,7 @@ static void test_tcs_init(void) /* Fail init on communication errors */ i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_FAIL_ALL_REG); - zassert_equal(-EIO, ms->drv->init(ms), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->init(ms), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Fail on bad ID */ @@ -70,11 +70,11 @@ static void test_tcs_read(void) /* Test error on writing registers */ i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ATIME); - zassert_equal(-EIO, ms->drv->read(ms, v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL); i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_CONTROL); - zassert_equal(-EIO, ms->drv->read(ms, v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL); i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ENABLE); - zassert_equal(-EIO, ms->drv->read(ms, v), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test starting read with calibration */ @@ -154,13 +154,13 @@ static void test_tcs_irq_handler_fail(void) event = TCS_INT_EVENT; /* Test error on reading status */ i2c_common_emul_set_read_fail_reg(emul, TCS_I2C_STATUS); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); check_fifo_empty(ms, ms_rgb); /* Test fail on changing device power state */ i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ENABLE); - zassert_equal(-EIO, ms->drv->irq_handler(ms, &event), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL); i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); check_fifo_empty(ms, ms_rgb); @@ -538,10 +538,10 @@ static void test_tcs_data_rate(void) /* Test fail on reading device power state */ i2c_common_emul_set_read_fail_reg(emul, TCS_I2C_ENABLE); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 0, 0), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 0, 1), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 100, 0), NULL); - zassert_equal(-EIO, ms->drv->set_data_rate(ms, 100, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 0, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 0, 1), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 100, 0), NULL); + zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 100, 1), NULL); i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG); /* Test setting 0 rate disables device */ |