From e1cb93e8d01a304e0fba0a6e144a64b968e0d277 Mon Sep 17 00:00:00 2001 From: Guangzong Chen Date: Wed, 1 May 2024 23:14:31 -0400 Subject: [PATCH] update --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/main.rs | 31 +++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f22ac1..3a234a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -605,6 +605,7 @@ dependencies = [ [[package]] name = "u5-lib" version = "0.1.0" +source = "git+ssh://gitea@git.ggeta.com:2002/guangzong/u5_new.git?rev=36dfec969e#36dfec969e0b2a455fbfa29b3b4d0194ac864b63" dependencies = [ "aligned", "cortex-m", diff --git a/Cargo.toml b/Cargo.toml index 83c9664..62c3e4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ edition = "2021" [dependencies] cortex-m = { version = "0.7.7" } aligned = "0.4.2" -u5-lib = { path = "../u5_new", features = ["utils"] } +#u5-lib = { path = "../u5_new", features = ["utils"] } +u5-lib = {git = "ssh://gitea@git.ggeta.com:2002/guangzong/u5_new.git", features = ["utils"], rev= "36dfec969e"} eb_cmds = { git = "ssh://gitea@git.ggeta.com:2002/guangzong/eb_cmds.git" } defmt = "0.3.6" diff --git a/src/main.rs b/src/main.rs index 3db2ab9..c52e6d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,27 +13,38 @@ use u5_lib::{ i2c, i2c::I2c, }; -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() +fn i2c_init() -> (I2c, I2c) { + let i2c_config_plus = i2c::I2cConfig::new(1, 100_000, gpio::I2C1_SCL_PB6, gpio::I2C1_SDA_PB3); + let i2c_plus = I2c::new(i2c_config_plus).unwrap(); + let i2c_config_minus = i2c::I2cConfig::new(2, 100_000, gpio::I2C2_SCL_PB13, gpio::I2C2_SDA_PB14); + let i2c_minus = I2c::new(i2c_config_minus).unwrap(); + (i2c_plus, i2c_minus) } #[task] async fn async_main(spawner: Spawner) { - // becareful, if the dbg is not enabled, but using deep sleep. This framework will not able to connect to chip. + // be careful, if the dbg is not enabled, but using deep sleep. This framework will not able to connect to chip. // stm32cube programmer, stmcubeide can be used to program the chip, then this framework can be used to debug. clock::init_clock(false, true, 16_000_000, true, clock::ClockFreqs::KernelFreq4Mhz); no_deep_sleep_request(); defmt::info!("setup led finished!"); - let green: gpio::GpioPort = gpio::PB7; + let red: gpio::GpioPort = gpio::PB7; + let green: gpio::GpioPort = gpio::PB8; green.setup(); - green.set_high(); - let i2c = i2c_init(); - panic!("panic"); + red.setup(); + let (mut i2c_plus, mut i2c_minus) = i2c_init(); + // let i2c_message = i2c::I2cMessage { + // addr: 0x68, + // data: &mut [0x75], + // }; + // i2c_plus.send(&i2c_message).unwrap(); + defmt::info!("i2c init finished!"); loop { - exti::EXTI13_PC13.wait_for_raising().await; + // exti::EXTI13_PC13.wait_for_raising().await; green.toggle(); - defmt::info!("toggle"); + red.toggle(); + delay_ms(500); + defmt::info!("toggle leds"); } }