Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active July 9, 2018 07:32
Show Gist options
  • Save lupyuen/0592ea2fc130b2616159e5845ec7554b to your computer and use it in GitHub Desktop.
Save lupyuen/0592ea2fc130b2616159e5845ec7554b to your computer and use it in GitHub Desktop.
// Get GPIO Port C, which also enables the Advanced Peripheral Bus 2 (APB2) clock for Port C.
let mut gpioc = bluepill.GPIOC.split(&mut rcc.apb2);
// Use Pin PC 13 of the Blue Pill for GPIO Port C. Select Output Push/Pull mode for the pin, which is connected to our LED.
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
...
// Loop forever.
loop {
// Output 3.3V on the LED Pin and show a message in OpenOCD console.
led.set_high();
writeln!(debug_out, "LED is ON!").unwrap();
// Wait 1,000 millisec (1 sec).
delay.delay_ms(1_000_u16);
// Output 0V on the LED Pin and show a message in OpenOCD console.
led.set_low();
writeln!(debug_out, "LED is OFF!").unwrap();
// Wait 1,000 millisec (1 sec).
delay.delay_ms(1_000_u16);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment