LOG_MODULE_REGISTER(monitor, LOG_LEVEL_DBG); #define DIE_TEMP_ALIAS DT_ALIAS(die_temp0) #define DIE_TEMPERATURE_SENSOR IF_ENABLED(DT_NODE_EXISTS(DIE_TEMP_ALIAS), DEVICE_DT_GET(DIE_TEMP_ALIAS)) static const struct device *const sensor = DIE_TEMPERATURE_SENSOR; #define STACKSIZE 512 #define MONITOR_THREAD_PRIORITY 15 static int print_die_temperature(const struct device *dev) { struct sensor_value val; int rc; /* fetch sensor samples */ rc = sensor_sample_fetch(dev); if (rc) { LOG_ERR("Failed to fetch sample (%d)", rc); return rc; } rc = sensor_channel_get(dev, SENSOR_CHAN_DIE_TEMP, &val); if (rc) { LOG_ERR("Failed to get data (%d)", rc); return rc; } LOG_DBG("CPU Die temperature[%s]: %d°C", dev->name, (int16_t)sensor_value_to_double(&val)); return 0; } void monitor_main(void) { if (!device_is_ready(sensor)) { LOG_ERR("sensor: device %s not ready.", sensor->name); } uint32_t counter = 0; while (true) { int rc = print_die_temperature(sensor); if (rc < 0) { LOG_ERR("Failed to print die temperature(err %d)", rc); } LOG_DBG("Counter: %d", counter++); k_msleep(1000); } } K_THREAD_DEFINE(monitor, STACKSIZE, monitor_main, NULL, NULL, NULL, MONITOR_THREAD_PRIORITY, 0, 10000);
this is the last log message from monitor thread, I never got any error message from the thread.