ism330dhcx with nrf54L15

Hello,
I try to do work a ism330dhcx on a custom digital board with a custom board in which there is a NRF54L15 microcontroller. The sensor works on other custom board with ST microcontroller.

Here is my code : 

for my overlay :

	// To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.
// For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html

&i2c22 {
    status = "okay";
    pinctrl-0 = <&i2c22_default>;
	pinctrl-1 = <&i2c22_sleep>;
    pinctrl-names = "default", "sleep";
    mysensor: ism330dhcx@6a {
        compatible = "st,ism330dhcx";
        reg = <0x6a>; /* Adresse définie par votre pin SDO */
		status = "okay";
		label = "ISM330DHCX";
    };
};

&pinctrl {
	/omit-if-no-ref/ i2c22_default: i2c22_default {
		group1  {
			psels = <NRF_PSEL(TWIM_SCL, 1, 8)>,
					<NRF_PSEL(TWIM_SDA, 2, 1)>;
					bias-pull-up;
            nordic,drive-mode = <NRF_DRIVE_S0D1>;
		};
	};

	/omit-if-no-ref/ i2c22_sleep: i2c22_sleep {
		group1  {
			psels = <NRF_PSEL(TWIM_SCL, 1, 8)>,
					<NRF_PSEL(TWIM_SDA, 2, 1)>;
			low-power-enable;
		};
	};
};
And this is my prj.conf : 

CONFIG_I2C=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_LOG=y
CONFIG_GPIO=y
CONFIG_SENSOR=y
CONFIG_ISM330DHCX=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_I2C_LOG_LEVEL_DBG=y
And my main.c :

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/drivers/i2c.h>
#include <stdio.h>
#include <zephyr/drivers/gpio.h>

#define EN_PIN 7
const struct device *gpio1_dev = DEVICE_DT_GET(DT_NODELABEL(gpio1));

// Dans main()


void main(void) {

    gpio_pin_configure(gpio1_dev, EN_PIN, GPIO_OUTPUT_ACTIVE);
k_msleep(100); // Laisse le temps au capteur de démarrer

struct i2c_dt_spec i2c_test = I2C_DT_SPEC_GET(DT_NODELABEL(mysensor));
uint8_t id_check = 0;
int err = i2c_reg_read_byte_dt(&i2c_test, 0x0F, &id_check);
if (err) {
    printk("Erreur I2C fatale : %d (Le bus ne répond pas)\n", err);
} else {
    printk("ID reçu : 0x%02X (Attendu: 0x6B)\n", id_check);
}

    const struct device *sensor = DEVICE_DT_GET_ANY(st_ism330dhcx);

    if (!device_is_ready(sensor)) {
        printk("Erreur : Capteur ISM330DHCX non prêt.\n");
        return;
    }

    /* Configuration via l'API Sensor (plus propre que l'I2C direct) */
    struct sensor_value attr;

    // Set ODR à 104 Hz
    attr.val1 = 104;
    attr.val2 = 0;
    sensor_attr_set(sensor, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &attr);

    // Set Full Scale à ±4g
    attr.val1 = 4;
    attr.val2 = 0;
    sensor_attr_set(sensor, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_FULL_SCALE, &attr);

    struct sensor_value accel[3];

    while (1) {
        if (sensor_sample_fetch(sensor) < 0) {
            printk("Erreur de lecture\n");
            continue;
        }

        sensor_channel_get(sensor, SENSOR_CHAN_ACCEL_XYZ, accel);

        /* Zephyr convertit automatiquement les données en m/s² */
        printf("Accel: X=%.4f Y=%.4f Z=%.4f m/s²\n",
               sensor_value_to_double(&accel[0]),
               sensor_value_to_double(&accel[1]),
               sensor_value_to_double(&accel[2]));

        k_msleep(300);
    }
}
I have an error which tells me that there is a fatal error -5. My sensor doen't connect with my custom board. 

Can you see why please ?

Thank you !

Parents Reply Children
No Data
Related