Hi, I just tried to connect LSM6DSV IMU with nRF52840dk
The whole folder structure is shown below :

1. I set nrf52840dk_nrf52840.overlay file first.
&spi2 {
status = "okay";
cs-gpios = <&gpio0 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
pinctrl-0 = <&spi2_default>;
pinctrl-1 = <&spi2_sleep>;
pinctrl-names = "default", "sleep";
lsm6dsv: lsm6dsl@0 {
compatible = "st,lsm6dsl";
reg = <0>;
spi-max-frequency = <10000000>;
};
};
&pinctrl {
spi2_default: spi2_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 0, 21)>,
<NRF_PSEL(SPIM_MOSI, 0, 20)>;
};
};
spi2_sleep: spi2_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 0, 21)>,
<NRF_PSEL(SPIM_MOSI, 0, 20)>;
low-power-enable;
};
};
};
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
#define CS_PIN 3
#define VDD_CTRL_PIN 10
#define SPI_MODE (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA)
static const struct spi_dt_spec lsm6dsv = SPI_DT_SPEC_GET(
DT_NODELABEL(lsm6dsv),
SPI_MODE,
0
);
void main(void)
{
const struct device *gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0));
gpio_pin_configure(gpio_dev, CS_PIN, GPIO_OUTPUT_LOW);
gpio_pin_configure(gpio_dev, VDD_CTRL_PIN, GPIO_OUTPUT_LOW);
LOG_INF("Initialize : CS LOW + Sensor VDD OFF");
k_msleep(100);
gpio_pin_set(gpio_dev, VDD_CTRL_PIN, 1);
LOG_INF("VDD ON");
k_msleep(100);
if (!spi_is_ready_dt(&lsm6dsv)) {
LOG_ERR("SPI not ready");
return;
}
uint8_t tx_buf[2] = { 0x8F, 0x00 };
uint8_t rx_buf[2] = { 0 };
const struct spi_buf tx = { .buf = tx_buf, .len = 2 };
const struct spi_buf rx = { .buf = rx_buf, .len = 2 };
const struct spi_buf_set tx_set = { .buffers = &tx, .count = 1 };
const struct spi_buf_set rx_set = { .buffers = &rx, .count = 1 };
int ret = spi_transceive_dt(&lsm6dsv, &tx_set, &rx_set);
if (ret == 0) {
LOG_INF("WHO_AM_I = 0x%02X", rx_buf[1]);
if (rx_buf[1] == 0x6C) {
LOG_INF("SPI comm DONE!");
} else {
LOG_ERR("Unexpected");
}
} else {
LOG_ERR("SPI transceive 실패: %d", ret);
}
k_msleep(500);
}[00:00:00.423,004] <inf> main: Initialize : CS LOW + Sensor VDD OFF
[00:00:00.523,101] <inf> main: VDD ON
[00:00:00.623,229] <inf> main: WHO_AM_I = 0x00
[00:00:00.623,260] <err> main: Unexpected