This repository demonstrates the application of C++ in embedded systems, specifically using STM32 microcontrollers. The goal is to provide a learning resource for developers transitioning from general C++ programming to embedded development. The project includes core components, hardware drivers, and practical examples, all aimed at showcasing the capabilities of STM32 microcontrollers and the efficiency of C++ in embedded programming.
In this project, I aim to implement Memory Mapped I/O (MMIO) for hardware interaction. MMIO maps peripheral control registers to specific memory addresses, allowing direct read/write operations on hardware registers through standard memory access instructions.
Memory Mapped I/O involves assigning a fixed range of memory addresses to hardware peripherals. Each peripheral has a set of registers that control its operation, and these registers are accessed by reading from or writing to the corresponding memory addresses. This method allows software to interact with hardware as if it were interacting with standard memory.
-
Efficiency: Directly accessing hardware registers via memory addresses eliminates the overhead associated with traditional I/O instructions, resulting in faster and more efficient hardware interactions.
-
Simplicity: Using pointers to access memory-mapped registers simplifies code, making it easier to read, write, and maintain.
-
Flexibility: MMIO allows for fine-grained control over hardware, enabling precise manipulation of peripheral settings and states.
-
Portability: Code using MMIO can be easily adapted to different microcontrollers with similar memory-mapped architectures by adjusting base addresses.
By using Memory Mapped I/O, we can leverage the full power of the STM32 microcontroller's hardware capabilities while maintaining efficient and readable code.
- Core/: Core components and configurations.
- Drivers/: Hardware drivers and related files.
- GPIO Class: Comprehensive implementation for STM32 microcontrollers.
- Modern C++: Utilizes C++11/14/17 features.
- HAL Integration: Seamless hardware control via STM32 HAL.
- STM32CubeIDE or a compatible IDE.
- Basic C++ and embedded systems knowledge.
- STM32 development board (e.g., STM32F4 Discovery, STM32 Nucleo).
- Clone the repository:
git clone https://github.com/MootSeeker/STM32_Embedded_CPP.git cd STM32_Embedded_CPP
- Open in STM32CubeIDE.
- Build and upload to your STM32 board.
- Complete GPIO class
- Implement class for Timer
- Implement class for ADC
- Implement class for DAC
- Implement class for CRC
- Implement class for SPI
- Implement class for I2C
- Implement class for CAN
- Implement class for QSPI
- Implement class for USART
- Create examples for all interfaces
- Transition to Bare Metal, removing HAL dependencies
Test status for each supported board.
MCU | Board name | RCC | GPIO | USART | Timer | Interrupts | I2C | SPI | I2S | Ethernet | ADC | DAC | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
F0 | |||||||||||||
STM32F042K6T | nucleo-f042k6 | ||||||||||||
STM32F051R8T | stm32f0-discovery | ||||||||||||
STM32F072C8Tx | otter_pill | ||||||||||||
F1 | |||||||||||||
STM32F103C8 | blue_pill | ||||||||||||
CH32F103C8 | blue_pill_wch | ||||||||||||
STM32F103CB | maple_mini | ||||||||||||
F4 | |||||||||||||
STM32F407VGT | stm32f4-discovery | ||||||||||||
L4 | |||||||||||||
STM32L433CCT | Fox Pill | ||||||||||||
STM32L496ZG | Nucleo-L496ZG-P | ||||||||||||
STM32L432KCU6 | nucleo-l432kc | ||||||||||||
F7 | |||||||||||||
STM32F746ZG | nucleo-f746zg |
- ✔: Module usable, though not all features may be implemented yet.
- 🚧: Currently being targeted for development & testing.
⚠️ : The feature cannot be supported by this board.- ?: The feature may work, but untested.
- C++
- C
- Assembly
Contributions are welcome! Please fork the repository, create a feature branch, commit your changes, and open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, please open an issue on the repository or contact MootSeeker.
Happy coding!