arch/arm/stm32h5: Add LPTIM support - #19959
Merged
Merged
Conversation
liam-geotab
requested review from
jerpelea,
raiden00pl and
simbit18
as code owners
August 24, 2026 20:06
Add LPTIM 1, 3, 4, 5 support. Based on STM32H7. setperiod and setcompare have been made to wait for the auto-reload value to be applied before returning. 6 is absent since generic stm32 configs for a 6th LPTIM are not present yet. 2 is absent for no good reason besides maybe that it's in a different RCC APB register. I am not adding support last-minute without more testing. The build fails noisily when LPTIM2 is enabled so the shortcoming is clear. Corrected some RCC definitions. They are needed for selecting the LPTIMx clock source. This is not done in the LPTIM driver. It is done outside and the definitions should ideally be correct for that. Signed-off-by: Liam Howatt <liamhowatt@geotab.com> Co-authored-by: Farzan Farhangian <farzanfarhangian@geotab.com>
Change to 'Yes' in the platform peripheral list and give the file path in the porting guide/status. Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
SPI support was added to nucleo-h563zi without the CMakeLists.txt SRCS list being updated to build stm32_spi.c. Add it. Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
liam-geotab
force-pushed
the
stm32h5-lptim
branch
from
August 24, 2026 20:12
ba11ffe to
f7aff4d
Compare
xiaoxiang781216
approved these changes
Aug 25, 2026
simbit18
approved these changes
Aug 25, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add LPTIM support.
The implementation is based on STM32H7. setperiod and setcompare have been made to wait for the auto-reload value to apply before returning.
STM32H5 has 6 LPTIMs. LPTIM2 has an incomplete implementation. It is in a different RCC APBx register than the other LPTIMs. Without contact with the author, I decided not to assume it's trivial to add without thorough testing so I left it as-is. The build fails if LPTIM2 is enabled so it's not a silent gap. I can try to add it, if that is the maintainers' wish. Supporting LPTIM6 would require the common configs to have LPTIM6 added.
Some STM32H5 RCC definitions have been corrected. It's necessary for the clock source selection that a user would do before using the STM32 LPTIM API.
Also add a missing CMakeLists.txt change that should have been in #19914
Impact
The changes are only additive except for RCC definition corrections.
LPTIM2 complete implementation is missing. LPTIM6 needs a common config added for it.
Testing
Nothing in the nuttx tree calls
stm32_lptim_initso here is how LPTIM has been sourced by the LSE (low speed external) clock to be used for the nuttx system tick on custom hardware. There is live adjustment of the timer period to deal with LSE modulo 100 Hz != 0.Enable
CONFIG_STM32_LPTIM1and override arch/arm/src/stm32h5/stm32_timerisr.c or modify it to use LPTIM1 as the tick source: