not working, fix at home, init hal from C was removed
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
// build.rs
|
// build.rs
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -25,6 +26,7 @@ fn main() {
|
|||||||
"stm32u5xx_hal_ramcfg.c",
|
"stm32u5xx_hal_ramcfg.c",
|
||||||
"stm32u5xx_hal_rtc.c",
|
"stm32u5xx_hal_rtc.c",
|
||||||
"stm32u5xx_hal_rtc_ex.c",
|
"stm32u5xx_hal_rtc_ex.c",
|
||||||
|
"stm32u5xx_hal_iwdg.c",
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut build = cc::Build::new();
|
let mut build = cc::Build::new();
|
||||||
@@ -42,6 +44,7 @@ fn main() {
|
|||||||
.include(&example_inc)
|
.include(&example_inc)
|
||||||
.define("USE_HAL_DRIVER", None)
|
.define("USE_HAL_DRIVER", None)
|
||||||
.define("STM32U575xx", None)
|
.define("STM32U575xx", None)
|
||||||
|
.define("HAL_IWDG_MODULE_ENABLED", None)
|
||||||
.flag("-mthumb")
|
.flag("-mthumb")
|
||||||
.flag("-march=armv8-m.main+fp.dp")
|
.flag("-march=armv8-m.main+fp.dp")
|
||||||
.flag("-mfloat-abi=hard")
|
.flag("-mfloat-abi=hard")
|
||||||
|
|||||||
@@ -3,11 +3,15 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
|
use core::ptr::addr_of_mut;
|
||||||
|
use embassy_stm32::pac;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_futures::yield_now;
|
use embassy_futures::yield_now;
|
||||||
use embassy_stm32::bind_interrupts;
|
use embassy_stm32::bind_interrupts;
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
use embassy_stm32::usart::{BufferedUart, Config, BufferedInterruptHandler};
|
use embassy_stm32::usart::{BufferedUart, Config, BufferedInterruptHandler};
|
||||||
|
use embassy_stm32::gpio::{Output, Level, Speed};
|
||||||
|
use embassy_time::{Duration, Timer};
|
||||||
|
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use dma_gpio::config::{
|
use dma_gpio::config::{
|
||||||
@@ -23,13 +27,20 @@ bind_interrupts!(struct Irqs {
|
|||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
fn HAL_Init();
|
fn HAL_Init();
|
||||||
fn HAL_PWR_EnterSTANDBYMode();
|
fn HAL_PWR_EnterSTANDBYMode();
|
||||||
fn HAL_PWREx_EnterSHUTDOWNMode();
|
fn HAL_IWDG_Init(handle: *mut ());
|
||||||
|
fn HAL_IWDG_Refresh(handle: *mut ());
|
||||||
|
fn __HAL_PWR_GET_FLAG(flag: u32) -> u32;
|
||||||
|
fn __HAL_PWR_CLEAR_FLAG(flag: u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PWR_FLAG_SBF: u32 = 1 << 1;
|
||||||
|
static mut IWDG_HANDLE: [u8; 64] = [0; 64];
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
info!("boot");
|
info!("boot");
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
let mut led = Output::new(p.PB0, Level::Low, Speed::Low);
|
||||||
info!("init m8");
|
info!("init m8");
|
||||||
|
|
||||||
// HARDWARE UART to the PC
|
// HARDWARE UART to the PC
|
||||||
@@ -50,18 +61,35 @@ async fn main(spawner: Spawner) {
|
|||||||
spawner.spawn(uart_task(uart, &PIPE_HW_TX, &PIPE_HW_RX).unwrap());
|
spawner.spawn(uart_task(uart, &PIPE_HW_TX, &PIPE_HW_RX).unwrap());
|
||||||
// END OF HARDWARE UART to the PC
|
// END OF HARDWARE UART to the PC
|
||||||
|
|
||||||
unsafe {
|
let pwr = pac::PWR;
|
||||||
HAL_Init();
|
|
||||||
HAL_PWR_EnterSTANDBYMode();
|
|
||||||
|
|
||||||
// Example 2 (unreachable if above executes): enter Shutdown
|
let from_standby = pwr.sr().read().sbf();
|
||||||
// HAL_PWREx_EnterSHUTDOWNMode();
|
if from_standby {
|
||||||
|
info!("Wake from Standby");
|
||||||
|
pwr.sr().write(|w| w.set_sbf(true));
|
||||||
}
|
}
|
||||||
|
info!("Iwdg 1 init");
|
||||||
|
info!("Iwdg 1 init");
|
||||||
|
unsafe {
|
||||||
|
HAL_IWDG_Init(addr_of_mut!(IWDG_HANDLE) as *mut ());
|
||||||
|
}
|
||||||
|
info!("Iwdg 2 init");
|
||||||
|
info!("Iwdg 2 init");
|
||||||
|
info!("Iwdg 2 init");
|
||||||
|
info!("Iwdg 2 init");
|
||||||
|
info!("Iwdg 2 init");
|
||||||
loop {
|
loop {
|
||||||
info!("tick start");
|
info!("tick start");
|
||||||
// Timer::after(Duration::from_millis(100)).await;
|
led.set_high();
|
||||||
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
// info!("tick end");
|
// info!("tick end");
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
info!("Standby...");
|
||||||
|
led.set_low();
|
||||||
|
HAL_IWDG_Refresh(addr_of_mut!(IWDG_HANDLE) as *mut ());
|
||||||
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
|
}
|
||||||
|
|
||||||
yield_now().await;
|
yield_now().await;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user