This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bmi160 zephyr sensor driver + nrf5340

Hi,

I have problem to use bmi160 library with nrf5340 in spi connection.

I use the example application zephyr/samples/sensor/adxl372 and change the sensor to bmi160 ( with zephyr driver).

device_is_ready(dev) is always not ready. Can some one help me debug why the device (bmi160) isn't initialized?  

my nrf5340dk_nrf5340_cpuapp.overlay config

&spi2 {
	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
	bmi160@76 {
		compatible = "bosch,bmi160";
		reg = <0x76>;
		spi-max-frequency = <8000000>;
		label = "BMI160";
		int-gpios = <&gpio0 20 0>;
	};
};

prj.conf 

CONFIG_STDOUT_CONSOLE=y
CONFIG_LOG=y
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_BMI160=y
CONFIG_BMI160_TRIGGER_OWN_THREAD=y
CONFIG_SENSOR_LOG_LEVEL_WRN=y
CONFIG_CBPRINTF_FP_SUPPORT=y
 

snippet in main.c 

void main(void)
{
	struct sensor_value accel[3];
	double mag;
	int i;
	char meter[200];

	const struct device *dev = DEVICE_DT_GET_ANY(bosch_bmi160);//

	if (!device_is_ready(dev)) {
		printf("Device %s is not ready\n", dev->name);
		return;
	}

In zephyr/drivers/sensor/bmi160/bmi160.c  line 985 

#define BMI160_DEVICE_INIT(inst)					\
	DEVICE_DT_INST_DEFINE(inst, bmi160_init, NULL,			\
			      &bmi160_data_##inst, &bmi160_cfg_##inst,	\
			      POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,	\
			      &bmi160_api);

The device is registered. This  is by far I can look into zephyr, however I don't have proper way to debug the zephyr system where a lots of function were formulated in macro.

Parents
  • Hi szhai lai, sorry for the long delay.

    Have you had any look at the SPI signals? Is there any activity at all? Would you be able to share a trace from an oscilloscope?

    Would you be able to share an image of your setup?

    You could also try lowering the clock frequency for SPI.

Reply
  • Hi szhai lai, sorry for the long delay.

    Have you had any look at the SPI signals? Is there any activity at all? Would you be able to share a trace from an oscilloscope?

    Would you be able to share an image of your setup?

    You could also try lowering the clock frequency for SPI.

Children
No Data
Related