Skip to content

Instantly share code, notes, and snippets.

@circuit4u-medium
Created October 12, 2021 22:31
Show Gist options
  • Save circuit4u-medium/7d40ee095f764cdde51717c29ef3a864 to your computer and use it in GitHub Desktop.
Save circuit4u-medium/7d40ee095f764cdde51717c29ef3a864 to your computer and use it in GitHub Desktop.
set blue pill LED using rust stm32 hal
#![no_std]
#![cfg_attr(not(doc), no_main)]
//use panic_rtt_target as _;
use panic_halt as _;
use cortex_m_rt::entry;
//use core::ptr;
//use stm32f1::stm32f103;
use stm32f1xx_hal::{pac, prelude::*};
//use embedded_hal::digital::v2::OutputPin;
#[entry]
fn main() -> ! {
// Get access to the device specific peripherals from the peripheral access crate
let dp = pac::Peripherals::take().unwrap();
let mut rcc = dp.RCC.constrain();
// Acquire the GPIOC peripheral
let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
// Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
// in order to configure the port. For pins 0-7, crl should be passed instead.
gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
loop {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment