formatting
This commit is contained in:
parent
8c88456fcb
commit
08d7289c93
1 changed files with 66 additions and 68 deletions
|
|
@ -113,10 +113,14 @@ unsafe fn enter_standby(pin: usize) {
|
||||||
// get current value of PWR_CTLR
|
// get current value of PWR_CTLR
|
||||||
let mut reg: u32 = 0x4000_7000;
|
let mut reg: u32 = 0x4000_7000;
|
||||||
let mut val: u32 = 0;
|
let mut val: u32 = 0;
|
||||||
unsafe { val = (reg as *mut u32).read_volatile(); }
|
unsafe {
|
||||||
|
val = (reg as *mut u32).read_volatile();
|
||||||
|
}
|
||||||
// modify PDDS
|
// modify PDDS
|
||||||
val |= 1 << 1; // PWR_CTLR[1] -> PDDS
|
val |= 1 << 1; // PWR_CTLR[1] -> PDDS
|
||||||
unsafe { (reg as *mut u32).write_volatile(val); }
|
unsafe {
|
||||||
|
(reg as *mut u32).write_volatile(val);
|
||||||
|
}
|
||||||
|
|
||||||
// // disable all exti interrupts
|
// // disable all exti interrupts
|
||||||
let exti = &hal::pac::EXTI;
|
let exti = &hal::pac::EXTI;
|
||||||
|
|
@ -130,7 +134,6 @@ unsafe fn enter_standby(pin: usize) {
|
||||||
let bits = 0xFFFFFFFF;
|
let bits = 0xFFFFFFFF;
|
||||||
exti.intfr().write(|w| w.0 = bits);
|
exti.intfr().write(|w| w.0 = bits);
|
||||||
|
|
||||||
|
|
||||||
// enable all exti interrupts
|
// enable all exti interrupts
|
||||||
let exti = &hal::pac::EXTI;
|
let exti = &hal::pac::EXTI;
|
||||||
exti.intenr().write(|w| {
|
exti.intenr().write(|w| {
|
||||||
|
|
@ -144,11 +147,9 @@ unsafe fn enter_standby(pin: usize) {
|
||||||
qingke::pfic::enable_interrupt(Interrupt::EXTI7_0 as u8);
|
qingke::pfic::enable_interrupt(Interrupt::EXTI7_0 as u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// execute WFI
|
// execute WFI
|
||||||
#[cfg(feature = "enable_print")]
|
#[cfg(feature = "enable_print")]
|
||||||
println!("WFI CONFIGURED HOPEFULLY");
|
println!("WFI CONFIGURED HOPEFULLY");
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +249,7 @@ use insert_coin::{TickService, TickServiceData};
|
||||||
|
|
||||||
fn debug_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
fn debug_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
// LED0 output setup
|
// LED0 output setup
|
||||||
use hal::gpio::{Output, Level};
|
use hal::gpio::{Level, Output};
|
||||||
let mut led0_pin = Output::new(p.PC3, Level::High, Default::default());
|
let mut led0_pin = Output::new(p.PC3, Level::High, Default::default());
|
||||||
|
|
||||||
// button pin setup
|
// button pin setup
|
||||||
|
|
@ -265,7 +266,9 @@ fn debug_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
// get the clocks re-initialized
|
// get the clocks re-initialized
|
||||||
let mut config = hal::Config::default();
|
let mut config = hal::Config::default();
|
||||||
config.rcc = hal::rcc::Config::SYSCLK_FREQ_48MHZ_HSI;
|
config.rcc = hal::rcc::Config::SYSCLK_FREQ_48MHZ_HSI;
|
||||||
unsafe { hal::rcc::init(config.rcc); }
|
unsafe {
|
||||||
|
hal::rcc::init(config.rcc);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "enable_print")]
|
#[cfg(feature = "enable_print")]
|
||||||
println!("begin loop");
|
println!("begin loop");
|
||||||
|
|
@ -277,7 +280,6 @@ fn debug_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
|
|
||||||
// === output setup ===
|
// === output setup ===
|
||||||
|
|
||||||
// LED0 output setup
|
// LED0 output setup
|
||||||
|
|
@ -543,7 +545,9 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
riscv::asm::wfi();
|
riscv::asm::wfi();
|
||||||
let mut config = hal::Config::default();
|
let mut config = hal::Config::default();
|
||||||
config.rcc = hal::rcc::Config::SYSCLK_FREQ_48MHZ_HSI;
|
config.rcc = hal::rcc::Config::SYSCLK_FREQ_48MHZ_HSI;
|
||||||
unsafe { hal::rcc::init(config.rcc); }
|
unsafe {
|
||||||
|
hal::rcc::init(config.rcc);
|
||||||
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
if INPUT_FLAGS.coin_flag {
|
if INPUT_FLAGS.coin_flag {
|
||||||
system_state = SystemState::Active;
|
system_state = SystemState::Active;
|
||||||
|
|
@ -551,10 +555,8 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
SystemState::Idle => {
|
SystemState::Idle => {}
|
||||||
|
|
||||||
},
|
|
||||||
SystemState::Active => {
|
SystemState::Active => {
|
||||||
tt0.tick();
|
tt0.tick();
|
||||||
tt1.tick();
|
tt1.tick();
|
||||||
|
|
@ -599,12 +601,8 @@ fn main() -> ! {
|
||||||
delay.delay_ms(1000);
|
delay.delay_ms(1000);
|
||||||
|
|
||||||
debug_main(p, delay);
|
debug_main(p, delay);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue