Enable clock by default for stm32l0
Modify init function to return a Clock instance defined by a per-chip SystemClock type and use this in macro setup A proof of concept implementation for STM32 L0 chips. This allows using embassy::main macros for STM32 devices that have the clock setup logic.
This commit is contained in:
@ -7,20 +7,17 @@ pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream
|
||||
let embassy_stm32_path = embassy_prefix.append("embassy_stm32").path();
|
||||
|
||||
quote!(
|
||||
use #embassy_stm32_path::{clock::Clock};
|
||||
use #embassy_stm32_path::{interrupt, peripherals, clock::Clock, time::Hertz};
|
||||
|
||||
let p = #embassy_stm32_path::init(#config);
|
||||
let (p, mut c) = #embassy_stm32_path::init(#config);
|
||||
|
||||
/*
|
||||
let mut rtc = #embass::RTC::new(unsafe { <peripherals::TIM2 as #embassy_path::util::Steal>::steal() }, interrupt::take!(TIM2));
|
||||
let rtc = unsafe { make_static(&mut rtc) };
|
||||
rtc.start();
|
||||
let mut alarm = rtc.alarm0();
|
||||
let clock = unsafe { make_static(&mut c) };
|
||||
clock.start();
|
||||
|
||||
unsafe { #embassy_path::time::set_clock(rtc) };
|
||||
let mut alarm = clock.alarm1();
|
||||
unsafe { #embassy_path::time::set_clock(clock) };
|
||||
|
||||
let alarm = unsafe { make_static(&mut alarm) };
|
||||
executor.set_alarm(alarm);
|
||||
*/
|
||||
)
|
||||
}
|
||||
|
@ -350,6 +350,13 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
unsafe {
|
||||
log::set_logger_racy(&LOGGER).unwrap();
|
||||
}
|
||||
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
log::info!("Hello World!");
|
||||
unsafe fn make_static<T>(t: &mut T) -> &'static mut T {
|
||||
::core::mem::transmute(t)
|
||||
}
|
||||
|
Reference in New Issue
Block a user