Created
February 17, 2020 02:25
-
-
Save ntr-808/05c3a0a8678afee64684c3ddd7d19eb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
#![no_main] | |
extern crate panic_semihosting; | |
use cortex_m_rt::entry; | |
use cortex_m_semihosting::{hprintln}; | |
use f411::{ | |
hal::{prelude::*, stm32, i2c::I2c}, | |
Lsm303dlhc, | |
}; | |
#[entry] | |
fn main() -> ! { | |
let p = stm32::Peripherals::take().unwrap(); | |
// let mut flash = p.FLASH.constrain(); | |
let rcc = p.RCC.constrain(); | |
let clocks = rcc.cfgr.freeze(); | |
let gpiob = p.GPIOB.split(); | |
let scl = gpiob.pb6.into_alternate_af4(); | |
let sda = gpiob.pb9.into_alternate_af4(); | |
let i2c = I2c::i2c1(p.I2C1, (scl, sda), 400.khz(), clocks); | |
let mut lsm303dlhc = Lsm303dlhc::new(i2c).unwrap(); | |
// never called | |
hprintln!("initialised lsm303dlhc").unwrap(); | |
let accel = lsm303dlhc.accel().unwrap(); | |
let mag = lsm303dlhc.mag().unwrap(); | |
let temp = lsm303dlhc.temp().unwrap(); | |
hprintln!("accel={:?}", accel).unwrap(); | |
hprintln!("mac={:?}", mag).unwrap(); | |
hprintln!("temp={:?}", temp).unwrap(); | |
loop {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment