-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: sensor: temperature: Add i.MX RT die temperature sensor #83880
Open
anedergaard
wants to merge
4
commits into
zephyrproject-rtos:main
Choose a base branch
from
anedergaard:driver-tmpsns-imxrt11xx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−1
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
27f1397
west: point nxp_hal module to PR reference for soc driver
anedergaard 14b52e0
dts: bindings: Add nxp i.MX RT die termerature binding
anedergaard 753dd74
drivers: sensor: temperature: Add i.MX RT die temperature sensor
anedergaard b891f14
tests: drivers: temp_sensor: Add overlay for i.MX RT1170-EVK
anedergaard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
zephyr_library() | ||
|
||
zephyr_library_sources(nxp_tmpsns.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# NXP i.MX RT temperature sensor configuration options | ||
|
||
# Copyright (c) 2025 Polytech A/S | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config NXP_TMPSNS | ||
bool "NXP TMPSNS sensor" | ||
depends on SENSOR | ||
depends on DT_HAS_NXP_TMPSNS_ENABLED | ||
depends on SOC_SERIES_IMXRT11XX || SOC_SERIES_IMXRT118X | ||
default y | ||
help | ||
Enable temperature measurement for NXP TMPSNS sensor | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,68 @@ | ||||||
/* | ||||||
* Copyright (c) 2025 Polytech A/S | ||||||
* | ||||||
* SPDX-License-Identifier: Apache-2.0 | ||||||
*/ | ||||||
|
||||||
#define DT_DRV_COMPAT nxp_tmpsns | ||||||
|
||||||
#include <fsl_tempsensor.h> | ||||||
#include <zephyr/drivers/sensor.h> | ||||||
|
||||||
struct nxp_tmpsns_data { | ||||||
float die_temp; | ||||||
}; | ||||||
|
||||||
static int nxp_tmpsns_channel_get(const struct device *dev, enum sensor_channel chan, | ||||||
struct sensor_value *val) | ||||||
{ | ||||||
const struct nxp_tmpsns_data *data = dev->data; | ||||||
|
||||||
switch (chan) { | ||||||
case SENSOR_CHAN_ALL: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this line. |
||||||
case SENSOR_CHAN_DIE_TEMP: | ||||||
return sensor_value_from_float(val, data->die_temp); | ||||||
default: | ||||||
return -ENOTSUP; | ||||||
} | ||||||
} | ||||||
|
||||||
static int nxp_tmpsns_channel_fetch(const struct device *dev, enum sensor_channel chan) | ||||||
{ | ||||||
struct nxp_tmpsns_data *data = dev->data; | ||||||
|
||||||
switch (chan) { | ||||||
case SENSOR_CHAN_ALL: | ||||||
case SENSOR_CHAN_DIE_TEMP: | ||||||
data->die_temp = TMPSNS_GetCurrentTemperature(TMPSNS); | ||||||
return 0; | ||||||
default: | ||||||
return -ENOTSUP; | ||||||
} | ||||||
} | ||||||
|
||||||
static const struct sensor_driver_api tmpsns_driver_api = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.channel_get = nxp_tmpsns_channel_get, | ||||||
.sample_fetch = nxp_tmpsns_channel_fetch, | ||||||
}; | ||||||
|
||||||
static int nxp_tmpsns_init(const struct device *dev) | ||||||
{ | ||||||
tmpsns_config_t config; | ||||||
|
||||||
TMPSNS_GetDefaultConfig(&config); | ||||||
config.measureMode = kTEMPSENSOR_ContinuousMode; | ||||||
config.frequency = 0x03U; | ||||||
TMPSNS_Init(TMPSNS, &config); | ||||||
TMPSNS_StartMeasure(TMPSNS); | ||||||
|
||||||
return 0; | ||||||
} | ||||||
|
||||||
#define NXP_TMPSNS_DEFINE(inst) \ | ||||||
struct nxp_tmpsns_data nxp_tmpsns_data_##inst; \ | ||||||
SENSOR_DEVICE_DT_INST_DEFINE(inst, nxp_tmpsns_init, NULL, &nxp_tmpsns_data_##inst, NULL, \ | ||||||
POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \ | ||||||
&tmpsns_driver_api); | ||||||
|
||||||
DT_INST_FOREACH_STATUS_OKAY(NXP_TMPSNS_DEFINE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,13 @@ | |
}; | ||
}; | ||
}; | ||
|
||
soc { | ||
temp: temp { | ||
compatible = "nxp,tmpsns"; | ||
status = "disabled"; | ||
}; | ||
}; | ||
}; | ||
|
||
&peripheral { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.