Read values from the ADC and pipe them to the terminal
These values look realistic!
This commit is contained in:
parent
b9ff4e8bb4
commit
1b2a368ae0
|
@ -3,7 +3,7 @@
|
|||
|
||||
pub use f3::hal::stm32f30x::{adc1, gpioa, gpioc, rcc};
|
||||
|
||||
use f3::hal::stm32f30x::{self, ADC1, ADC1_2, GPIOA, GPIOD, GPIOE, RCC};
|
||||
use f3::hal::stm32f30x::{self, ADC1, ADC1_2, ITM, GPIOA, GPIOD, GPIOE, RCC};
|
||||
|
||||
pub struct Peripherals {
|
||||
pub gpioa: GPIOA,
|
||||
|
@ -11,12 +11,14 @@ pub struct Peripherals {
|
|||
pub gpioe: GPIOE,
|
||||
pub rcc: RCC,
|
||||
pub adc1: ADC1,
|
||||
pub adc1_2: ADC1_2
|
||||
pub adc1_2: ADC1_2,
|
||||
pub itm: ITM,
|
||||
}
|
||||
|
||||
pub fn init() -> Peripherals {
|
||||
// restrict access to the other peripherals
|
||||
let per = stm32f30x::Peripherals::take().unwrap();
|
||||
let core_per = stm32f30x::CorePeripherals::take().unwrap();
|
||||
|
||||
Peripherals {
|
||||
gpioa: per.GPIOA,
|
||||
|
@ -25,5 +27,6 @@ pub fn init() -> Peripherals {
|
|||
rcc: per.RCC,
|
||||
adc1: per.ADC1,
|
||||
adc1_2: per.ADC1_2,
|
||||
itm: core_per.ITM,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,13 @@ extern crate panic_itm; // panic handler
|
|||
|
||||
mod bsp;
|
||||
|
||||
use cortex_m::iprintln;
|
||||
use cortex_m::asm::{bkpt, delay};
|
||||
use cortex_m_rt::entry;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let per = bsp::init();
|
||||
let mut per = bsp::init();
|
||||
|
||||
// Configure clock gates
|
||||
per.rcc.ahbenr.modify(|_, w| {
|
||||
|
@ -235,6 +236,7 @@ fn main() -> ! {
|
|||
per.gpioe.odr.modify(|_, w| {
|
||||
w.odr8().bit(push_button)
|
||||
});
|
||||
iprintln!(&mut per.itm.stim[0], "ADC: {:x}", per.adc1.dr.read().bits());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue