55#![ no_main]
66#![ no_std]
77
8- extern crate cortex_m;
9- extern crate cortex_m_rt as rt;
10- extern crate mpu9250;
11- extern crate panic_semihosting;
12- extern crate stm32f1xx_hal as hal;
8+ use panic_halt as _;
139
1410use cortex_m:: asm;
15- use hal::delay::Delay;
16- use hal::prelude::*;
17- use hal::spi::Spi;
18- use hal::stm32f103xx;
11+ use cortex_m_rt:: entry;
1912use mpu9250:: Mpu9250 ;
20- use rt::{entry, exception, ExceptionFrame};
13+ use stm32f1xx_hal as hal;
14+
15+ use hal:: { pac, prelude:: * , spi:: Spi } ;
2116
2217#[ entry]
2318fn main ( ) -> ! {
2419 let cp = cortex_m:: Peripherals :: take ( ) . unwrap ( ) ;
25- let dp = stm32f103xx ::Peripherals::take().unwrap();
20+ let dp = pac :: Peripherals :: take ( ) . unwrap ( ) ;
2621
2722 let mut flash = dp. FLASH . constrain ( ) ;
28- let mut rcc = dp.RCC.constrain();
23+ let rcc = dp. RCC . constrain ( ) ;
2924
3025 let clocks = rcc. cfgr . freeze ( & mut flash. acr ) ;
3126
@@ -46,36 +41,25 @@ fn main() -> ! {
4641 // let miso = gpiob.pb14;
4742 // let mosi = gpiob.pb15.into_alternate_push_pull(&mut gpiob.crh);
4843
49- let spi = Spi::spi1 (
44+ let spi = Spi :: new (
5045 dp. SPI1 ,
51- (sck, miso, mosi),
52- &mut afio.mapr,
53- mpu9250::MODE,
46+ ( sck, miso, mosi, & mut afio. mapr ) ,
47+ mpu9250:: MODE . into ( ) ,
5448 1 . MHz ( ) ,
55- clocks,
49+ & clocks,
5650 ) ;
5751
58- let mut delay = Delay::new( cp.SYST, &clocks);
52+ let mut delay = cp. SYST . delay ( & clocks) ;
5953
60- let mut mpu9250 = Mpu9250::marg (spi, nss, &mut delay).unwrap();
54+ let mut mpu9250 = Mpu9250 :: marg_default ( spi, nss, & mut delay) . unwrap ( ) ;
6155
6256 // sanity checks
6357 assert_eq ! ( mpu9250. who_am_i( ) . unwrap( ) , 0x71 ) ;
6458 assert_eq ! ( mpu9250. ak8963_who_am_i( ) . unwrap( ) , 0x48 ) ;
6559
66- let _a = mpu9250.all().unwrap();
60+ let _a = mpu9250. all :: < [ f32 ; 3 ] > ( ) . unwrap ( ) ;
6761
6862 asm:: bkpt ( ) ;
6963
7064 loop { }
7165}
72-
73- #[exception]
74- fn HardFault(ef: &ExceptionFrame) -> ! {
75- panic!("{:#?}", ef);
76- }
77-
78- #[exception]
79- fn DefaultHandler(irqn: i16) {
80- panic!("Unhandled exception (IRQn = {})", irqn);
81- }
0 commit comments