Skip to main content
Visitor II
Feb 9, 2026 9:14 AM UTC
Question

source code of protocols

Hello everyone,

I am currently working on a project to develop drivers for STM32F4 microcontrollers, based on Reference Manual RM0090 (without HAL, only CMSIS and register access).

The goal of the project is to design reusable low-level drivers for the following peripherals:

  • USART / UART

  • SPI

  • I2C

I am now in the code implementation phase.

I would like the community's help with the following:

  1. Examples of source code or references (preferably bare-metal / register level) for:

    • SPI : transmission et réception

    • I2C : master transmit / master receive

    • UART : transmission et réception

  2. Recommendations on API structure and function naming, for example:

    • SPI_Init(), SPI_Transmit(), SPI_Receive()

    • I2C_MasterTransmit(), I2C_MasterReceive()

    • USART_Transmit(), USART_Receive()

Any help, code snippets, links to reference implementations, or feedback would be greatly appreciated.

Thank you in advance for your help.

Best regards,

 

*This post has been translated from French to comply with the ST Community guidelines.

2 replies

TDK
Feb 9, 2026 2:31 PM UTC

There are lots of LL library examples. Maybe those will give you some inspiration. HAL library is also perfectly usable. You can re-implement as register access if desired.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Ozone
Principal
Feb 9, 2026 2:49 PM UTC

The "legacy" SPL is still available for download at ST for the F4 devices, which provides a relatively thin abstraction layer.
Although it contains some bloated code as well that tries to be too generic.

I often take SPL code as a template in my projects, and strip it down to the functionality required.
Which usually means copying the "register access" code from the SPL functions, and adapting it.