diff --git a/samples/sensor/bmg160/src/main.c b/samples/sensor/bmg160/src/main.c index 18fbfcf87f0..7201dab4070 100644 --- a/samples/sensor/bmg160/src/main.c +++ b/samples/sensor/bmg160/src/main.c @@ -17,6 +17,10 @@ #define MAX_TEST_TIME 15000 #define SLEEPTIME 300 +#if !DT_HAS_COMPAT_STATUS_OKAY(bosch_bmg160) +#error "No bosch,bmg160 compatible node found in the device tree" +#endif + static void print_gyro_data(const struct device *bmg160) { struct sensor_value val[3]; @@ -173,10 +177,6 @@ void main(void) struct sensor_value attr; #endif - if (!bmg160) { - printf("Device not found.\n"); - return; - } if (!device_is_ready(bmg160)) { printf("Device %s is not ready.\n", bmg160->name); return;