updated example
This commit is contained in:
@@ -13,11 +13,7 @@ use log::{error, info};
|
||||
use mmc56x3::MMC56X3;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
for _ in 0..20 {
|
||||
error!("PANIC: {info}");
|
||||
}
|
||||
info!("Doing cold boot from panic");
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
embassy_rp::rom_data::reset_to_usb_boot(0, 0);
|
||||
|
||||
loop {}
|
||||
@@ -46,23 +42,30 @@ async fn main(spawner: Spawner) {
|
||||
let i2c = I2c::new_async(p.I2C0, scl, sda, Irqs, i2c::Config::default());
|
||||
|
||||
let mut device = MMC56X3::new(i2c, Delay);
|
||||
device.init().await.expect("Failed to init");
|
||||
if let Err(e) = device.init().await {
|
||||
error!("Failed to init {:?}", e);
|
||||
reboot().await;
|
||||
};
|
||||
|
||||
device
|
||||
.set_data_rate(mmc56x3::DataRate::Hz(100))
|
||||
.await
|
||||
.expect("Failed to set data rate");
|
||||
if let Err(e) = device.set_data_rate(mmc56x3::DataRate::Max1000Hz).await {
|
||||
error!("Failed to set data rate {:?}", e);
|
||||
reboot().await;
|
||||
}
|
||||
|
||||
device
|
||||
.set_continuous_mode(true)
|
||||
.await
|
||||
.expect("Failed to set continuous mode");
|
||||
if let Err(e) = device.set_continuous_mode(true).await {
|
||||
error!("Failed to set_continuous_mode {:?}", e);
|
||||
reboot().await;
|
||||
}
|
||||
|
||||
for _ in 0..20 {
|
||||
Timer::after_secs(1).await;
|
||||
for _ in 0..200 {
|
||||
Timer::after_millis(50).await;
|
||||
|
||||
// let result = device.read_temperature().await;
|
||||
// device.trigger_messurement().await.expect("Failed to trigger trigger_messurement");
|
||||
// info!("T: {:?}", result);
|
||||
// device
|
||||
// .trigger_messurement()
|
||||
// .await
|
||||
// .expect("Failed to trigger trigger_messurement");
|
||||
|
||||
match device.read_messurement().await {
|
||||
Ok(d) => info!("Got: {:?}", d),
|
||||
@@ -70,6 +73,10 @@ async fn main(spawner: Spawner) {
|
||||
}
|
||||
}
|
||||
|
||||
reboot().await;
|
||||
}
|
||||
|
||||
async fn reboot() {
|
||||
info!("Doing cold boot");
|
||||
Timer::after_secs(1).await;
|
||||
embassy_rp::rom_data::reset_to_usb_boot(0, 0);
|
||||
|
||||
Reference in New Issue
Block a user