Temp might be working now.
This commit is contained in:
parent
3abad6bd86
commit
92229431e3
29
src/main.rs
29
src/main.rs
|
@ -4,13 +4,12 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use bsp::{
|
||||
entry,
|
||||
hal::gpio,
|
||||
};
|
||||
use bsp::{entry, hal::gpio};
|
||||
use defmt::*;
|
||||
use defmt_rtt as _;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use embedded_hal::spi::MODE_0;
|
||||
use max31855::{Max31855, Unit};
|
||||
use panic_probe as _;
|
||||
|
||||
// Provide an alias for our BSP so we can switch targets quickly.
|
||||
|
@ -19,8 +18,10 @@ use rp_pico as bsp;
|
|||
|
||||
use bsp::hal::{
|
||||
clocks::{init_clocks_and_plls, Clock},
|
||||
fugit::RateExtU32,
|
||||
pac,
|
||||
sio::Sio,
|
||||
spi::Spi,
|
||||
watchdog::Watchdog,
|
||||
};
|
||||
|
||||
|
@ -58,14 +59,26 @@ fn main() -> ! {
|
|||
let mut led_pin = pins.led.into_push_pull_output();
|
||||
let mut external_led_pin = pins.gpio14.into_push_pull_output();
|
||||
//clk
|
||||
let _thermometer_spi_sck = pins.gpio2.into_function::<gpio::FunctionSpi>();
|
||||
let thermometer_spi_sck = pins.gpio2.into_function::<gpio::FunctionSpi>();
|
||||
//MOSI, I think unused?
|
||||
let thermometer_spi_tx = pins.gpio3.into_function::<gpio::FunctionSpi>();
|
||||
//do, or MISO.
|
||||
let _thermometer_spi_rx = pins.gpio4.into_function::<gpio::FunctionSpi>();
|
||||
let thermometer_spi_rx = pins.gpio4.into_function::<gpio::FunctionSpi>();
|
||||
//cs
|
||||
let _thermometer_spi_csn = pins
|
||||
let mut thermometer_spi_csn = pins
|
||||
.gpio5
|
||||
.into_push_pull_output_in_state(gpio::PinState::Low);
|
||||
|
||||
let thermometer_spi_device = pac.SPI0;
|
||||
let spi_pin_layout = (thermometer_spi_tx, thermometer_spi_rx, thermometer_spi_sck);
|
||||
let mut spi = Spi::<_, _, _, 8>::new(thermometer_spi_device, spi_pin_layout).init(
|
||||
&mut pac.RESETS,
|
||||
125_000_000u32.Hz(),
|
||||
4u32.MHz(),
|
||||
MODE_0,
|
||||
);
|
||||
|
||||
|
||||
loop {
|
||||
led_pin.set_high().unwrap();
|
||||
external_led_pin.set_low().unwrap();
|
||||
|
@ -73,5 +86,7 @@ fn main() -> ! {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
BIN
wiring.fzz
BIN
wiring.fzz
Binary file not shown.
Loading…
Reference in a new issue