Let FlashLayout and FlashRegion depends on a Blocking/Async mode generic
This commit is contained in:
@ -213,7 +213,7 @@ fn main() {
|
||||
let region_type = format_ident!("{}", get_flash_region_type_name(region.name));
|
||||
flash_regions.extend(quote! {
|
||||
#[cfg(flash)]
|
||||
pub struct #region_type<'d>(pub &'static crate::flash::FlashRegion, pub(crate) embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>,);
|
||||
pub struct #region_type<'d, MODE>(pub &'static crate::flash::FlashRegion, pub(crate) embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>, pub(crate) core::marker::PhantomData<MODE>);
|
||||
});
|
||||
}
|
||||
|
||||
@ -224,11 +224,11 @@ fn main() {
|
||||
let field_name = format_ident!("{}", region_name.to_lowercase());
|
||||
let field_type = format_ident!("{}", get_flash_region_type_name(f.name));
|
||||
let field = quote! {
|
||||
pub #field_name: #field_type<'d>
|
||||
pub #field_name: #field_type<'d, MODE>
|
||||
};
|
||||
let region_name = format_ident!("{}", region_name);
|
||||
let init = quote! {
|
||||
#field_name: #field_type(&#region_name, unsafe { p.clone_unchecked()})
|
||||
#field_name: #field_type(&#region_name, unsafe { p.clone_unchecked()}, core::marker::PhantomData)
|
||||
};
|
||||
|
||||
(field, (init, region_name))
|
||||
@ -238,15 +238,17 @@ fn main() {
|
||||
let regions_len = flash_memory_regions.len();
|
||||
flash_regions.extend(quote! {
|
||||
#[cfg(flash)]
|
||||
pub struct FlashLayout<'d> {
|
||||
#(#fields),*
|
||||
pub struct FlashLayout<'d, MODE> {
|
||||
#(#fields),*,
|
||||
_mode: core::marker::PhantomData<MODE>,
|
||||
}
|
||||
|
||||
#[cfg(flash)]
|
||||
impl<'d> FlashLayout<'d> {
|
||||
impl<'d, MODE> FlashLayout<'d, MODE> {
|
||||
pub(crate) fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
|
||||
Self {
|
||||
#(#inits),*
|
||||
#(#inits),*,
|
||||
_mode: core::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user