STM32F103 HAL is a lightweight, no_std hardware abstraction layer (HAL) for the STM32F103 series of ARM Cortex-M microcontrollers. This crate is designed to simplify access to and control of STM32F103 peripherals while maintaining a strong focus on safety and ease of use.
- No standard library: Suitable for bare-metal and embedded environments, built with
#![no_std]
. - Runtime support: Provides a reset handler, panic handler, and vector table.
- GPIO abstraction: Support for configuring and controlling GPIO pins with a simple and safe API.
i am actively working on expanding the support for additional STM32F103 peripherals. Here is the upcoming roadmap:
- EXTI (External Interrupts): Handle external interrupts for GPIO pins.
- UART: Add support for serial communication (Universal Asynchronous Receiver-Transmitter).
- SPI: Enable Serial Peripheral Interface support for communication with SPI-based devices.
- I2C: Support for the Inter-Integrated Circuit (I2C) protocol.
- Timers: Abstractions for working with hardware timers, including basic, general-purpose, and advanced timers.
- Other peripherals: Future development will include ADC, DAC, CAN, PWM, etc.
First, you need to add the stm32f103-hal
crate to your project. Add the following to your Cargo.toml
:
[dependencies]
stm32f103-hal = { git = "https://github.com/Abdelrahmanosama372/stm32f103-hal-rs", features = ["rt"] }
Since this is a no_std
project, you'll need to configure your project appropriately. Ensure your main.rs
starts with:
#![no_std]
#![no_main]
A complete example that demonstrates configuring and toggling an LED on GPIO pin PA1 is provided in the examples directory. To build the example:
cargo build --example gpio_example
To build and flash this example onto your STM32F103 microcontroller in a single step, use cargo flash:
cargo flash --chip stm32f103c8 --example gpio_example
This command compiles the example and flashes the resulting binary to your microcontroller.
This project is licensed under the MIT License. See the LICENSE file for details.