Skip to content

Instantly share code, notes, and snippets.

@therealprof
Last active February 12, 2019 11:51
Show Gist options
  • Save therealprof/9be63ca6701a769f8c3cf86558ad0487 to your computer and use it in GitHub Desktop.
Save therealprof/9be63ca6701a769f8c3cf86558ad0487 to your computer and use it in GitHub Desktop.
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use stm32f0xx_hal as hal;
use crate::hal::delay::Delay;
use crate::hal::prelude::*;
use crate::hal::stm32;
use cortex_m::peripheral::Peripherals;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
if let (Some(p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
let gpioa = p.GPIOA.split();
/* (Re-)configure PA1 as output */
let mut led = gpioa.pa1.into_push_pull_output();
/* Constrain clocking registers */
let rcc = p.RCC.constrain();
/* Configure clock to 8 MHz (i.e. the default) and freeze it */
let clocks = rcc.cfgr.sysclk(8.mhz()).freeze();
/* Get delay provider */
let mut delay = Delay::new(cp.SYST, clocks);
loop {
led.toggle();
delay.delay_ms(1_000_u16);
}
}
loop {
continue;
}
}
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use stm32f0xx_hal as hal;
use crate::hal::delay::Delay;
use crate::hal::prelude::*;
use crate::hal::stm32;
use cortex_m::peripheral::Peripherals;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
if let (Some(p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
let gpioa = p.GPIOA.split();
/* (Re-)configure PA1 as output */
let mut led = gpioa.pa1.into_push_pull_output();
/* Constrain clocking registers */
let rcc = p.RCC.constrain();
/* Configure clock to 8 MHz (i.e. the default) and freeze it */
let clocks = rcc.cfgr.sysclk(8.mhz()).freeze();
/* Get delay provider */
let mut delay = Delay::new(cp.SYST, clocks);
loop {
led.set_high();
delay.delay_ms(1_000_u16);
led.set_low();
delay.delay_ms(1_000_u16);
}
}
loop {
continue;
}
}
Bloat for example blinky_delay
Compiling ...
Analyzing target/thumbv6m-none-eabi/release/examples/blinky_delay
File .text Size Crate Name
0.0% 0.0% 0B [0 Others]
0.1% 39.7% 236B [Unknown] main
0.1% 24.2% 144B [Unknown] __udivmodsi4
0.1% 21.2% 126B [Unknown] __clzsi2
0.0% 10.8% 64B cortex_m_rt Reset
0.0% 3.0% 18B [Unknown] __aeabi_uidivmod
0.0% 0.3% 2B cortex_m_rt HardFault_
0.0% 0.3% 2B cortex_m_rt DefaultPreInit
0.0% 0.3% 2B cortex_m_rt DefaultHandler_
0.3% 100.0% 594B .text section size, the file size is 193.4KiB
Bloat for example blinky_delay_udiv
Compiling ...
Analyzing target/thumbv6m-none-eabi/release/examples/blinky_delay_udiv
File .text Size Crate Name
0.0% 0.0% 0B [0 Others]
0.1% 25.4% 212B [Unknown] main
0.1% 17.3% 144B [Unknown] __udivmodsi4
0.1% 15.6% 130B [Unknown] __aeabi_uidiv
0.1% 15.1% 126B [Unknown] __clzsi2
0.1% 14.4% 120B stm32f0xx_hal <stm32f0xx_hal::delay::Delay as embedded_hal::blocking::delay::DelayMs<u16>>::delay_ms
0.0% 7.7% 64B cortex_m_rt Reset
0.0% 2.2% 18B [Unknown] __aeabi_uidivmod
0.0% 0.7% 6B std core::panicking::panic
0.0% 0.7% 6B std core::panicking::panic_fmt
0.0% 0.2% 2B cortex_m_rt HardFault_
0.0% 0.2% 2B panic_halt rust_begin_unwind
0.0% 0.2% 2B cortex_m_rt DefaultPreInit
0.0% 0.2% 2B cortex_m_rt DefaultHandler_
0.4% 100.0% 834B .text section size, the file size is 195.4KiB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment