Twizzle our DMA vs BDMA channels.

This commit is contained in:
Bob McWhirter 2021-07-12 10:32:57 -04:00
parent a24a7e9fec
commit 97ad434d38
3 changed files with 38 additions and 18 deletions

View file

@ -236,7 +236,6 @@ macro_rules! impl_dma_channel {
#[cfg(not(dmamux))]
impl<T> WriteDma<T> for crate::peripherals::$channel_peri
where
Self: crate::dmamux::sealed::PeripheralChannel<T, crate::dmamux::M2P>,
T: 'static,
{
type WriteDmaFuture<'a> = impl Future<Output = ()>;
@ -358,7 +357,7 @@ macro_rules! impl_dma_channel {
pac::peripherals! {
(bdma, DMA1) => {
impl_dma!(DMA1, 0);
pac::dma_channels! {
pac::bdma_channels! {
($channel_peri:ident, DMA1, $channel_num:expr) => {
impl_dma_channel!($channel_peri, DMA1, 0, $channel_num);
};
@ -366,7 +365,7 @@ pac::peripherals! {
};
(bdma, DMA2) => {
impl_dma!(DMA2, 1);
pac::dma_channels! {
pac::bdma_channels! {
($channel_peri:ident, DMA2, $channel_num:expr) => {
impl_dma_channel!($channel_peri, DMA2, 1, $channel_num);
};
@ -375,8 +374,8 @@ pac::peripherals! {
// Because H7cm changes the naming
(bdma, BDMA) => {
impl_dma!(BDMA, 0);
pac::dma_channels! {
($channel_peri:ident, DMA1, $channel_num:expr) => {
pac::bdma_channels! {
($channel_peri:ident, BDMA, $channel_num:expr) => {
impl_dma_channel!($channel_peri, BDMA, 0, $channel_num);
};
}
@ -421,7 +420,7 @@ pac::peripheral_dma_channels! {
#[cfg(dmamux)]
pac::peripherals! {
(usart, $peri:ident) => {
pac::dma_channels! {
pac::bdma_channels! {
($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => {
impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { }
impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { }
@ -429,7 +428,7 @@ pac::peripherals! {
}
};
(uart, $peri:ident) => {
pac::dma_channels! {
pac::bdma_channels! {
($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => {
impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { }
impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { }

View file

@ -11,7 +11,7 @@ use crate::interrupt;
use crate::pac::bdma::{regs, vals};
use crate::pac;
use crate::pac::dma_channels;
use crate::pac::bdma_channels;
use crate::pac::dma_requests;
use crate::pac::interrupts;
use crate::pac::peripheral_count;
@ -170,19 +170,26 @@ macro_rules! impl_dmamux {
peripherals! {
(bdma, DMA1) => {
dma_channels! {
bdma_channels! {
($channel_peri:ident, DMA1, $channel_num:expr) => {
impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA1, 0);
};
}
};
(bdma, DMA2) => {
dma_channels! {
bdma_channels! {
($channel_peri:ident, DMA2, $channel_num:expr) => {
impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1);
};
}
};
(bdma, BDMA) => {
bdma_channels! {
($channel_peri:ident, BDMA, $channel_num:expr) => {
impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1);
};
}
};
(dmamux, DMAMUX1) => {
impl_dmamux!(DMAMUX1);
};
@ -243,7 +250,7 @@ macro_rules! impl_usart_dma_requests {
#[cfg(usart)]
use crate::usart;
dma_channels! {
bdma_channels! {
($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => {
impl_usart_dma_requests!($channel_peri, $dma_peri, $channel_num);
};

View file

@ -252,6 +252,7 @@ pub fn gen(options: Options) {
let mut peripheral_pins_table: Vec<Vec<String>> = Vec::new();
let mut peripheral_rcc_table: Vec<Vec<String>> = Vec::new();
let mut dma_channels_table: Vec<Vec<String>> = Vec::new();
let mut bdma_channels_table: Vec<Vec<String>> = Vec::new();
let mut dma_requests_table: Vec<Vec<String>> = Vec::new();
let mut peripheral_dma_channels_table: Vec<Vec<String>> = Vec::new();
let mut peripheral_counts: HashMap<String, u8> = HashMap::new();
@ -266,13 +267,7 @@ pub fn gen(options: Options) {
let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address;
let gpio_stride = 0x400;
for (id, channel_info) in &core.dma_channels {
let mut row = Vec::new();
row.push(id.clone());
row.push(channel_info.dma.clone());
row.push(channel_info.channel.to_string());
dma_channels_table.push(row);
}
let number_suffix_re = Regex::new("^(.*?)[0-9]*$").unwrap();
@ -449,6 +444,24 @@ pub fn gen(options: Options) {
dev.peripherals.push(ir_peri);
}
for (id, channel_info) in &core.dma_channels {
let mut row = Vec::new();
let dma_peri = core.peripherals.get(&channel_info.dma);
row.push(id.clone());
row.push(channel_info.dma.clone());
row.push(channel_info.channel.to_string());
if let Some(dma_peri) = dma_peri {
if let Some(ref block) = dma_peri.block {
let bi = BlockInfo::parse(block);
if bi.module == "bdma" {
bdma_channels_table.push(row);
} else {
dma_channels_table.push(row);
}
}
}
}
for (name, &num) in &core.interrupts {
dev.interrupts.push(ir::Interrupt {
name: name.clone(),
@ -495,6 +508,7 @@ pub fn gen(options: Options) {
);
make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table);
make_table(&mut extra, "dma_channels", &dma_channels_table);
make_table(&mut extra, "bdma_channels", &bdma_channels_table);
make_table(&mut extra, "dma_requests", &dma_requests_table);
make_peripheral_counts(&mut extra, &peripheral_counts);