kywwilson11 opened a new pull request, #16746:
URL: https://github.com/apache/nuttx/pull/16746
## Summary
This commit adds full support for the on‑die digital temperature sensor
(DTS) in the STM32H5 family:
- **Driver**: Implements `stm32h5_dts` low‑level driver
(`chip/stm32_dts.[ch]`) with:
- Software trigger, CFGR1 configuration (sample time, reference clock,
trigger source)
- Raw → frequency → °C conversion using factory calibration registers
- Interrupt support for end‑of‑measurement, high/low threshold (both
synchronous and LSE‑only asynchronous wakeup)
- `get_info()` updated with realistic sensor parameters
- Currently no support for HW Triggers. set_interval not developed. Need
LP Timer support first.
- **Kconfig**: New options under `Drivers → Sensors → STM32H5 DTS`:
- `CONFIG_STM32H5_DTS` to enable the driver
- `CONFIG_STM32H5_DTS_REFCLK_LSE` to select LSE vs PCLK
- `CONFIG_STM32H5_DTS_SMP_TIME` for TS1_SMP_TIME
- Interrupt‑enable flags for ITEF/ITLF/ITHF and AITEF/AITLF/AITHF
- **Build**: Updated `Kconfig` and `Make.defs` so the peripheral clock
(APB1HENR DTSEN) and driver files are included when enabled
- **uORB**: Exposes `/dev/uorb/sensor_tempN` via the NuttX sensors framework
## Impact
- **New functionality**: Enables temperature sensing on with DTS
STM32H5‑based boards (e.g., NUCLEO‑H563ZI)
- **Build-time**: Zero impact unless `CONFIG_STM32H5_DTS=y`
- **Runtime**: Negligible idle overhead; active only during measurements or
threshold events
- **Compatibility**: No changes to other families; coexists with existing
sensors drivers
## Testing
Modes: PCLK and LSE
Interupts: Did not test hardware trigger mode. But enabled interrupts while
in SW trigger mode. isr was accessed and fetch was not affected.
Samples: Tested number of samples. Verified with debugger.
Wrote a very simple external app to test. See below.
Not shown here but I heated and cooled the chip and watched changes. Below
output is with 125MHz PCLK1.
Example Output:
```console
NuttShell (NSH) NuttX-12.10.0
nsh> dts
Time: 2550000 µs Temp: 29.39 °C
nsh> dts
Time: 3840000 µs Temp: 29.39 °C
nsh> dts
Time: 4950000 µs Temp: 29.39 °C
nsh> dts
Time: 6060000 µs Temp: 29.26 °C
nsh> dts
Time: 7740000 µs Temp: 29.39 °C
nsh>
```
Kconfig options:
<img width="723" height="318" alt="dts_kconfig"
src="https://github.com/user-attachments/assets/3c91eb84-5c2c-476a-95e3-e1a3b6635590"
/>
External Test Application:
```
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <nuttx/sensors/ioctl.h>
#include <nuttx/sensors/sensor.h>
#include <nuttx/uorb.h>
int main(void)
{
int usfd = open("/dev/usensor", O_RDWR);
if (usfd < 0)
{
perror("open /dev/usensor");
return 1;
}
struct sensor_reginfo_s reginfo =
{
.path = "/dev/uorb/sensor_temp", /* note: no trailing ‘0’ */
.esize = sizeof(struct sensor_temp),
.nbuffer= 1
};
if (ioctl(usfd, SNIOC_REGISTER, (unsigned long)®info) < 0)
{
}
close(usfd);
int fd = open("/dev/uorb/sensor_temp0", O_RDONLY | O_NONBLOCK);
if (fd < 0) { perror("open"); return 1; }
struct sensor_temp report;
for (int i = 0; i < 1; i++)
{
if (read(fd, &report, sizeof(report)) != sizeof(report))
{
perror("read");
break;
}
printf("Time: %llu µs Temp: %.2f °C\n",
(unsigned long long)report.timestamp,
report.temperature);
}
close(fd);
return 0;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]