Migrate exti_irq stuff to macro tables.

This commit is contained in:
Bob McWhirter 2021-06-03 13:35:27 -04:00
parent 75dc0fd542
commit fe47f781be
4 changed files with 43 additions and 15 deletions

View File

@ -140,10 +140,10 @@ with open(output_file, 'w') as f:
# if re.match('TIM[2345]$', name): # if re.match('TIM[2345]$', name):
# f.write(f'impl_timer!({name});') # f.write(f'impl_timer!({name});')
if block_mod == 'exti': # if block_mod == 'exti':
for irq in chip['interrupts']: # for irq in chip['interrupts']:
if re.match('EXTI', irq): # if re.match('EXTI', irq):
exti_interrupts.append(irq) # exti_interrupts.append(irq)
# if block_mod == 'dac': # if block_mod == 'dac':
# f.write(f'impl_dac!({name});') # f.write(f'impl_dac!({name});')
@ -160,4 +160,4 @@ with open(output_file, 'w') as f:
f.write(f"embassy_extras::peripherals!({','.join(singletons)});") f.write(f"embassy_extras::peripherals!({','.join(singletons)});")
# ========= exti interrupts # ========= exti interrupts
f.write(f"impl_exti_irq!({','.join(exti_interrupts)});") # f.write(f"impl_exti_irq!({','.join(exti_interrupts)});")

View File

@ -214,6 +214,7 @@ impl_exti!(EXTI15, 15);
pub(crate) unsafe fn init() {} pub(crate) unsafe fn init() {}
/*
macro_rules! impl_exti_irq { macro_rules! impl_exti_irq {
($($e:ident),+) => { ($($e:ident),+) => {
/// safety: must be called only once /// safety: must be called only once
@ -234,3 +235,24 @@ macro_rules! impl_exti_irq {
)+ )+
}; };
} }
*/
/// safety: must be called only once
pub(crate) unsafe fn init_exti() {
use embassy::interrupt::Interrupt;
use embassy::interrupt::InterruptExt;
crate::pac::exti_interrupts!(
($e:ident) => {
crate::interrupt::$e::steal().enable();
};
);
}
crate::pac::exti_interrupts!(
($e:ident) => {
unsafe fn $e() {
on_irq()
}
};
);

View File

@ -83,7 +83,7 @@ pub fn init(config: Config) -> Peripherals {
#[cfg(dma)] #[cfg(dma)]
dma::init(); dma::init();
generated::init_exti(); exti::init_exti();
rcc::init(config.rcc); rcc::init(config.rcc);
} }

View File

@ -176,7 +176,6 @@ fn main() {
peripheral_pins_table.push(row); peripheral_pins_table.push(row);
} }
cfgs.insert(bi.module.clone()); cfgs.insert(bi.module.clone());
cfgs.insert(format!("{}_{}", bi.module, bi.version)); cfgs.insert(format!("{}_{}", bi.module, bi.version));
let mut peripheral_row = Vec::new(); let mut peripheral_row = Vec::new();
@ -256,8 +255,15 @@ fn main() {
.map(|(kind, version)| vec![kind.clone(), version.clone()]) .map(|(kind, version)| vec![kind.clone(), version.clone()])
.collect(); .collect();
let exti_interrupt_table = &interrupt_table
.iter()
.filter(|row| row[0].contains("EXTI"))
.map(|row| row.clone())
.collect();
make_table(&mut extra, "pins", &pin_table); make_table(&mut extra, "pins", &pin_table);
make_table(&mut extra, "interrupts", &interrupt_table); make_table(&mut extra, "interrupts", &interrupt_table);
make_table(&mut extra, "exti_interrupts", &exti_interrupt_table);
make_table(&mut extra, "peripherals", &peripherals_table); make_table(&mut extra, "peripherals", &peripherals_table);
make_table(&mut extra, "peripheral_versions", &peripheral_version_table); make_table(&mut extra, "peripheral_versions", &peripheral_version_table);
make_table(&mut extra, "peripheral_pins", &peripheral_pins_table); make_table(&mut extra, "peripheral_pins", &peripheral_pins_table);