MCU LED Now turns on!

This commit is contained in:
2025-04-03 23:21:05 -04:00
parent a4df453ec9
commit fd661b8ae4
2 changed files with 14 additions and 1 deletions

View File

@@ -10,7 +10,10 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7"
cortex-m-semihosting = "0.5"
panic-halt = "1.0.0"
stm32f1 = "0.15.1"
[dependencies.stm32f1]
version = "0.15.1"
features = ["stm32f103"]
# Uncomment for the panic example.
# panic-itm = "0.4.1"

View File

@@ -10,12 +10,22 @@ use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch
use cortex_m::asm;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use stm32f1::stm32f103;
#[entry]
fn main() -> ! {
asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
hprintln!("Hello, world!");
let peripherals = stm32f103::Peripherals::take().unwrap();
// Enable clock for GPIOA by setting IOPAEN in RCC APB2ENR
peripherals.RCC.apb2enr.modify(|_, w| w.iopaen().set_bit());
peripherals.GPIOA.crl.modify(|_, w| w.mode3().output());
peripherals.GPIOA.crl.modify(|_, w| w.cnf3().push_pull());
peripherals.GPIOA.odr.modify(|_, w| w.odr3().high());
loop {
// your code goes here
asm::nop();