got temp printing out over serial!
This commit is contained in:
parent
92229431e3
commit
4e1956f30d
38
src/main.rs
38
src/main.rs
|
@ -4,8 +4,14 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use bsp::{entry, hal::gpio};
|
||||
use defmt::*;
|
||||
use core::fmt::Write;
|
||||
use bsp::{
|
||||
entry,
|
||||
hal::{
|
||||
gpio,
|
||||
uart::{UartConfig, UartPeripheral},
|
||||
},
|
||||
};
|
||||
use defmt_rtt as _;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use embedded_hal::spi::MODE_0;
|
||||
|
@ -27,7 +33,6 @@ use bsp::hal::{
|
|||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("Program start");
|
||||
let mut pac = pac::Peripherals::take().unwrap();
|
||||
let core = pac::CorePeripherals::take().unwrap();
|
||||
let mut watchdog = Watchdog::new(pac.WATCHDOG);
|
||||
|
@ -56,6 +61,22 @@ fn main() -> ! {
|
|||
&mut pac.RESETS,
|
||||
);
|
||||
|
||||
let uart_pins = (pins.gpio0.into_function(), pins.gpio1.into_function());
|
||||
let mut uart = UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||
.enable(
|
||||
UartConfig::new(
|
||||
9600u32.Hz(),
|
||||
bsp::hal::uart::DataBits::Eight,
|
||||
None,
|
||||
bsp::hal::uart::StopBits::One,
|
||||
),
|
||||
clocks.peripheral_clock.freq(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
defmt::info!("Program start");
|
||||
writeln!(uart, "Program start\r",).unwrap();
|
||||
|
||||
let mut led_pin = pins.led.into_push_pull_output();
|
||||
let mut external_led_pin = pins.gpio14.into_push_pull_output();
|
||||
//clk
|
||||
|
@ -78,15 +99,16 @@ fn main() -> ! {
|
|||
MODE_0,
|
||||
);
|
||||
|
||||
|
||||
loop {
|
||||
led_pin.set_high().unwrap();
|
||||
external_led_pin.set_low().unwrap();
|
||||
delay.delay_ms(1000);
|
||||
delay.delay_ms(500);
|
||||
led_pin.set_low().unwrap();
|
||||
external_led_pin.set_high().unwrap();
|
||||
delay.delay_ms(1000);
|
||||
let value = spi.read_thermocouple(&mut thermometer_spi_csn, Unit::Celsius).unwrap();
|
||||
info!("temp is {}", value);
|
||||
delay.delay_ms(500);
|
||||
match spi.read_thermocouple(&mut thermometer_spi_csn, Unit::Celsius) {
|
||||
Ok(v) => writeln!(uart, "Temp: {} \r", v).unwrap(),
|
||||
Err(e) => defmt::error!("error reading temp {}", defmt::Debug2Format(&e)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue