update
This commit is contained in:
parent
cc1c3facf3
commit
e1cb93e8d0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
31
src/main.rs
31
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user