-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8080207
commit 5df95b9
Showing
5 changed files
with
68 additions
and
68 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
fn main() { | ||
println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
} | ||
fn main() { | ||
println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use embassy_executor::Spawner; | ||
use embassy_time::{Duration, Timer}; | ||
use hyped_boards_stm32l476rg::tasks::temperature::read_temp; | ||
use {defmt_rtt as _, panic_probe as _}; | ||
|
||
#[embassy_executor::main] | ||
async fn main(spawner: Spawner) -> ! { | ||
spawner.spawn(read_temp()).unwrap(); | ||
|
||
loop { | ||
Timer::after(Duration::from_secs(1)).await; | ||
} | ||
} | ||
#![no_std] | ||
#![no_main] | ||
|
||
use embassy_executor::Spawner; | ||
use embassy_time::{Duration, Timer}; | ||
use hyped_boards_stm32l476rg::tasks::temperature::read_temp; | ||
use {defmt_rtt as _, panic_probe as _}; | ||
|
||
#[embassy_executor::main] | ||
async fn main(spawner: Spawner) -> ! { | ||
spawner.spawn(read_temp()).unwrap(); | ||
|
||
loop { | ||
Timer::after(Duration::from_secs(1)).await; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub mod i2c; | ||
pub mod i2c; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub mod temperature; | ||
pub mod temperature; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
use crate::io::i2c::Stm32l476rgI2c; | ||
use defmt_rtt as _; | ||
use embassy_stm32::i2c::I2c; | ||
use embassy_stm32::time::Hertz; | ||
use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; | ||
|
||
/// Test task that just reads the temperature from the sensor and prints it to the console | ||
#[embassy_executor::task] | ||
pub async fn read_temp() -> ! { | ||
let p = embassy_stm32::init(Default::default()); | ||
let i2c = I2c::new_blocking(p.I2C1, p.PB8, p.PB9, Hertz(100_000), Default::default()); | ||
let hyped_i2c = Stm32l476rgI2c::new(i2c); | ||
|
||
let mut temperature_sensor = Temperature::new(hyped_i2c, TemperatureAddresses::Address3f) | ||
.expect( | ||
"Failed to create temperature sensor. Check the wiring and the I2C address of the sensor.", | ||
); | ||
|
||
loop { | ||
match temperature_sensor.check_status() { | ||
Status::TempOverUpperLimit => { | ||
defmt::error!("Temperature is over the upper limit."); | ||
} | ||
Status::TempUnderLowerLimit => { | ||
defmt::error!("Temperature is under the lower limit."); | ||
} | ||
Status::Busy => { | ||
defmt::warn!("Temperature sensor is busy."); | ||
} | ||
Status::Unknown => { | ||
panic!("Could not get the status of the temperature sensor.") | ||
} | ||
Status::Ok => {} | ||
} | ||
|
||
match temperature_sensor.read() { | ||
Some(temperature) => { | ||
defmt::info!("Temperature: {:?}", temperature); | ||
} | ||
None => { | ||
defmt::info!("Failed to read temperature."); | ||
} | ||
} | ||
} | ||
} | ||
use crate::io::i2c::Stm32l476rgI2c; | ||
use defmt_rtt as _; | ||
use embassy_stm32::i2c::I2c; | ||
use embassy_stm32::time::Hertz; | ||
use hyped_sensors::temperature::{Status, Temperature, TemperatureAddresses}; | ||
|
||
/// Test task that just reads the temperature from the sensor and prints it to the console | ||
#[embassy_executor::task] | ||
pub async fn read_temp() -> ! { | ||
let p = embassy_stm32::init(Default::default()); | ||
let i2c = I2c::new_blocking(p.I2C1, p.PB8, p.PB9, Hertz(100_000), Default::default()); | ||
let hyped_i2c = Stm32l476rgI2c::new(i2c); | ||
|
||
let mut temperature_sensor = Temperature::new(hyped_i2c, TemperatureAddresses::Address3f) | ||
.expect( | ||
"Failed to create temperature sensor. Check the wiring and the I2C address of the sensor.", | ||
); | ||
|
||
loop { | ||
match temperature_sensor.check_status() { | ||
Status::TempOverUpperLimit => { | ||
defmt::error!("Temperature is over the upper limit."); | ||
} | ||
Status::TempUnderLowerLimit => { | ||
defmt::error!("Temperature is under the lower limit."); | ||
} | ||
Status::Busy => { | ||
defmt::warn!("Temperature sensor is busy."); | ||
} | ||
Status::Unknown => { | ||
panic!("Could not get the status of the temperature sensor.") | ||
} | ||
Status::Ok => {} | ||
} | ||
|
||
match temperature_sensor.read() { | ||
Some(temperature) => { | ||
defmt::info!("Temperature: {:?}", temperature); | ||
} | ||
None => { | ||
defmt::info!("Failed to read temperature."); | ||
} | ||
} | ||
} | ||
} |