Blink an LED - Embedded-rust Typing CST Test
Loading…
Blink an LED — Embedded-rust Code
Toggle an LED on pin 13 every 500 ms using Embedded Rust.
#![no_std]
#![no_main]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f4xx_hal::{prelude::*, stm32};
#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().unwrap();
let gpiod = dp.GPIOD.split();
let mut led = gpiod.pd12.into_push_pull_output();
loop {
led.toggle().unwrap();
cortex_m::asm::delay(8_000_000);
}
}Embedded-rust Language Guide
Embedded Rust refers to using the Rust programming language to develop software for embedded systems, microcontrollers, and resource-constrained devices. It focuses on safety, performance, and concurrency without relying on runtime environments or garbage collection.
Primary Use Cases
- ▸Firmware development for microcontrollers
- ▸Real-time control of sensors and actuators
- ▸IoT device programming and communication
- ▸Embedded systems prototyping and development
- ▸Safety-critical and low-level hardware software
Notable Features
- ▸Memory safety without runtime overhead
- ▸Zero-cost abstractions and high performance
- ▸Strong type system preventing common bugs
- ▸Hardware-level control through HALs and PACs
- ▸Support for concurrency and async programming
Origin & Creator
Rust was created by Mozilla in 2010 to offer a safe, fast, and concurrent systems programming language. Embedded Rust emerged through the community’s adaptation of Rust for microcontroller and bare-metal programming.
Industrial Note
Embedded Rust is increasingly adopted in safety-critical industries such as automotive, aerospace, and industrial IoT for reliable, memory-safe firmware development.