123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #![cfg_attr(test, allow(unused_imports))]
- #![cfg_attr(not(test), no_std)]
- #![cfg_attr(not(test), no_main)]
- // pick a panicking behavior
- #[cfg(not(test))]
- use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
- // use panic_abort as _; // requires nightly
- // use panic_itm as _; // logs messages over ITM; requires ITM support
- // use panic_semihosting as _; // logs messages to the host stderr; requires a debugger
- // use cortex_m::asm;
- use cortex_m_rt::entry;
- // use stm32l4::stm32l4x2;
- use stm32l4xx_hal::{prelude::*, pac, rcc};
- use cortex_m_semihosting::{debug, hprintln};
- #[cfg(not(test))]
- #[entry]
- fn main() -> ! {
- // asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
- hprintln!("Hello, world!").unwrap();
- let peripherals = pac::Peripherals::take().unwrap();
- let _core = cortex_m::Peripherals::take().unwrap();
- let gpioa = &peripherals.GPIOA;
- gpioa.odr.modify(|_, w| w.odr0().set_bit());
- loop {
- // your code goes here
- }
- }
- fn add(a: i32, b: i32) -> i32 {
- a + b
- }
- #[cfg(test)]
- mod test {
- use super::*;
- #[test]
- fn foo() {
- println!("tests work!");
- assert!(2 == add(1,1));
- }
- }
|