RTEMS | stm32h7/spi-support: correct bugs and improve safety in SPI HAL (!1162)

Mohamed Ayman (@mohamedayman23) gitlab at rtems.org
Wed Mar 25 07:44:46 UTC 2026



Mohamed Ayman created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1162

Project:Branches: mohamedayman23/rtems:fix-stm32h7-spi-support-bugs to rtems/rtos/rtems:main
Author:   Mohamed Ayman



## Summary

stm32h7/spi-support: correct bugs and improve safety in SPI HAL

- Fix transfer loop “final” condition in stm32h7_spi_apply_postmessage_settings: previous code used i == msg_count, which is never true. Now correctly uses i == (msg_count - 1).
- Reset ctx-\>error before starting transfers in stm32h7_spi_txrx, stm32h7_spi_tx, and stm32h7_spi_rx. Prevents old errors from persisting when using interrupts.
- Prevent division by zero in prescaler calculation: return early if speed_hz == 0.
- Guard against unsafe usage of \_Bitfield_Leading_zeros: return early if divider == 0 to avoid undefined logic.
- Correct return type in stm32h7_register_spi_device: previously returned false in int function, now returns -1.
- DMA alignment check now guards against NULL pointers: check if pRxData != NULL before evaluating alignment.

AI Usage: yes

AI prompt: how the developer struct this very long file what is the best milestones he do and the baddest ideas and give me the flow to write one for a different family.

AI Model: GPT-5 mini

How AI Used: to struct and understanding big file.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1162
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260325/9ae495bb/attachment-0001.htm>


More information about the bugs mailing list