I2C master driver problems using Zephy Devicetree method.

Dear sir:

We use the VS code IDE with NRF connect SDK 2.4.0 for matter door lock application.

We have the problems with the I2C master driver to the motor device.

The DT overlay file is defined as follow:

&i2c0 {
    compatible = "nordic,nrf-twi";
    status = "okay";
    clock-frequency = <I2C_BITRATE_FAST>;
    pinctrl-0 = <&i2c0_default>;
    pinctrl-1 = <&i2c0_sleep>;
    pinctrl-names = "default", "sleep";
    locktiny: locktiny@60 {
        reg = <0x60>;
        label = "LOCKTINY";
    };
And the prj.conf is defined as follow:
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# This sample uses Kconfig.defaults to set options common for all
# samples. This file should contain only options specific for this sample
# or overrides of default values.

# Enable CHIP
CONFIG_CHIP=y
CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h"
# 32774 == 0x8006 (example lock-app)
CONFIG_CHIP_DEVICE_PRODUCT_ID=32774
CONFIG_STD_CPP14=y

# Add support for LEDs and buttons on Nordic development kits
CONFIG_DK_LIBRARY=y

# Add support for I2C device driver
CONFIG_I2C=y

# Bluetooth Low Energy configuration
CONFIG_BT_DEVICE_NAME="MatterLock"

# Other settings
CONFIG_THREAD_NAME=y
CONFIG_MPU_STACK_GUARD=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_CHIP_LIB_SHELL=y

# Reduce application size
CONFIG_USE_SEGGER_RTT=n
And the application code is applied as list
app_task.cpp
.....
#include <zephyr/drivers/i2c.h>
.....
#define I2C0_NODE DT_NODELABEL(locktiny)
static const struct i2c_dt_spec dev_i2c = I2C_DT_SPEC_GET(I2C0_NODE);
The application driver function write_tiny()
void writeTiny(unsigned char command)
{
    // PLAT_LOG("writeTiny started");
    // GPIO_write(CONFIG_GPIO_MTRINT, 0); // wakeup MCU
    LOG_INF("Enter writeTiny");
    gpio_pin_set_dt(&mtrint, 1);
    //while (GPIO_read(CONFIG_GPIO_MTRACT))
    while (gpio_pin_get_dt(&mtract))
    {
        // wait for MCU wake-up    
        k_busy_wait(10);
        LOG_INF("waiting for device ready");
    }

    txBuffer[0] = command;
    LOG_INF("Starting i2c write command");
    i2c_write_dt(&dev_i2c, txBuffer, 1);   //Problems here

    // GPIO_write(CONFIG_GPIO_MTRINT, 1); // wakeup MCU
    gpio_pin_set_dt(&mtrint, 0);
    // while (!GPIO_read(CONFIG_GPIO_MTRACT))
    while (!gpio_pin_get_dt(&mtract))
    {
        // wait for MCU wake-up    
        k_busy_wait(10);
    }
    // PLAT_LOG("writeTiny finished");
}
My problems are call the  function i2c_write_dt(); with slave address 0x60 and the command 0xa3
But the error console message is show as follow.
It seems like the write data problems. How can I slove the issue?


Related