From cc1c3facf39072362e1e2a53bbb245b4ff7d865e Mon Sep 17 00:00:00 2001 From: Guangzong Chen Date: Wed, 1 May 2024 17:17:53 -0400 Subject: [PATCH] update --- Cargo.toml | 8 ++------ src/main.rs | 29 ++++++++++------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 84c3f3a..83c9664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,19 +11,15 @@ edition = "2021" [dependencies] cortex-m = { version = "0.7.7" } aligned = "0.4.2" -u5-lib = { path="../u5_new", features = [ -# "stm32u5a5zj", -], default-features = false } +u5-lib = { path = "../u5_new", features = ["utils"] } eb_cmds = { git = "ssh://gitea@git.ggeta.com:2002/guangzong/eb_cmds.git" } -#critical-section = "1.1.2" defmt = "0.3.6" defmt-rtt = { version = "0.4.0" } -#defmt-itm = { version = "0.3.0" } futures = { version = "0.3.17", default-features = false, fetures = [ "async-await", ] } -cortex-m-rt = { version = "0.7.3" , default-features = false } +cortex-m-rt = { version = "0.7.3", default-features = false } [dependencies.embassy-usb] diff --git a/src/main.rs b/src/main.rs index 8663975..3db2ab9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,29 +3,19 @@ #![no_main] #![feature(type_alias_impl_trait)] -use core::panic::PanicInfo; -use aligned::Aligned; -use defmt::println; - use defmt_rtt as _; use embassy_executor::Spawner; use u5_lib::{ *, - clock::delay_ms, - com_interface::ComInterface, + low_power::{Executor, no_deep_sleep_request}, + clock, clock::delay_ms, com_interface::ComInterface, exti, gpio, task, + i2c, i2c::I2c, }; -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - defmt::info!("panic"); - defmt::error!( - "Location file name: {:?}, line: {:?}, col: {:?}", - _info.location().unwrap().file(), - _info.location().unwrap().line(), - _info.location().unwrap().column() - ); - loop {} +fn i2c_init() -> I2c { + let i2c_config = i2c::I2cConfig::new(1, 100_000, gpio::I2C1_SCL_PB6, gpio::I2C1_SDA_PB7); + I2c::new(i2c_config).unwrap() } #[task] @@ -38,6 +28,8 @@ async fn async_main(spawner: Spawner) { let green: gpio::GpioPort = gpio::PB7; green.setup(); green.set_high(); + let i2c = i2c_init(); + panic!("panic"); loop { exti::EXTI13_PC13.wait_for_raising().await; green.toggle(); @@ -45,12 +37,11 @@ async fn async_main(spawner: Spawner) { } } -use low_power::Executor; -use u5_lib::low_power::no_deep_sleep_request; #[cortex_m_rt::entry] fn main() -> ! { Executor::take().run(|spawner| { spawner.spawn(async_main(spawner)).unwrap(); }); -} \ No newline at end of file +} +