Migrate sdmmc to macro tables.
This commit is contained in:
parent
fe47f781be
commit
2c722ec0ee
@ -48,48 +48,6 @@ with open(output_file, 'w') as f:
|
|||||||
|
|
||||||
custom_singletons = False
|
custom_singletons = False
|
||||||
|
|
||||||
# if block_mod == 'usart':
|
|
||||||
# f.write(f'impl_usart!({name});')
|
|
||||||
# for pin, funcs in af.items():
|
|
||||||
# if pin in pins:
|
|
||||||
# if (func := funcs.get(f'{name}_RX')) != None:
|
|
||||||
# f.write(f'impl_usart_pin!({name}, RxPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_TX')) != None:
|
|
||||||
# f.write(f'impl_usart_pin!({name}, TxPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_CTS')) != None:
|
|
||||||
# f.write(f'impl_usart_pin!({name}, CtsPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_RTS')) != None:
|
|
||||||
# f.write(f'impl_usart_pin!({name}, RtsPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_CK')) != None:
|
|
||||||
# f.write(f'impl_usart_pin!({name}, CkPin, {pin}, {func});')
|
|
||||||
|
|
||||||
# if block_mod == 'rng':
|
|
||||||
# for irq in chip['interrupts']:
|
|
||||||
# if re.search('RNG', irq):
|
|
||||||
# f.write(f'impl_rng!({name}, {irq});')
|
|
||||||
|
|
||||||
# if block_mod == 'spi':
|
|
||||||
# if 'clock' in peri:
|
|
||||||
# clock = peri['clock']
|
|
||||||
# f.write(f'impl_spi!({name}, {clock});')
|
|
||||||
# for pin, funcs in af.items():
|
|
||||||
# if pin in pins:
|
|
||||||
# if (func := funcs.get(f'{name}_SCK')) != None:
|
|
||||||
# f.write(f'impl_spi_pin!({name}, SckPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_MOSI')) != None:
|
|
||||||
# f.write(f'impl_spi_pin!({name}, MosiPin, {pin}, {func});')
|
|
||||||
# if (func := funcs.get(f'{name}_MISO')) != None:
|
|
||||||
# f.write(f'impl_spi_pin!({name}, MisoPin, {pin}, {func});')
|
|
||||||
|
|
||||||
# if block_mod == 'i2c':
|
|
||||||
# f.write(f'impl_i2c!({name});')
|
|
||||||
# for pin, funcs in af.items():
|
|
||||||
# if pin in pins:
|
|
||||||
# if func := funcs.get(f'{name}_SCL'):
|
|
||||||
# f.write(f'impl_i2c_pin!({name}, SclPin, {pin}, {func});')
|
|
||||||
# if func := funcs.get(f'{name}_SDA'):
|
|
||||||
# f.write(f'impl_i2c_pin!({name}, SdaPin, {pin}, {func});')
|
|
||||||
|
|
||||||
if block_mod == 'gpio':
|
if block_mod == 'gpio':
|
||||||
custom_singletons = True
|
custom_singletons = True
|
||||||
port = name[4:]
|
port = name[4:]
|
||||||
@ -111,53 +69,7 @@ with open(output_file, 'w') as f:
|
|||||||
|
|
||||||
f.write(f'impl_dma_channel!({channel}, {dma_num}, {ch_num});')
|
f.write(f'impl_dma_channel!({channel}, {dma_num}, {ch_num});')
|
||||||
|
|
||||||
if peri['block'] == 'sdmmc_v2/SDMMC':
|
|
||||||
f.write(f'impl_sdmmc!({name});')
|
|
||||||
for pin, funcs in af.items():
|
|
||||||
if pin in pins:
|
|
||||||
if (func := funcs.get(f'{name}_CK')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, CkPin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_CMD')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, CmdPin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D0')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D0Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D1')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D1Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D2')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D2Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D3')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D3Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D4')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D4Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D5')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D5Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D6')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D6Pin, {pin}, {func});')
|
|
||||||
if (func := funcs.get(f'{name}_D7')) != None:
|
|
||||||
f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});')
|
|
||||||
|
|
||||||
# if block_name == 'TimGp16':
|
|
||||||
# if re.match('TIM[2345]$', name):
|
|
||||||
# f.write(f'impl_timer!({name});')
|
|
||||||
|
|
||||||
# if block_mod == 'exti':
|
|
||||||
# for irq in chip['interrupts']:
|
|
||||||
# if re.match('EXTI', irq):
|
|
||||||
# exti_interrupts.append(irq)
|
|
||||||
|
|
||||||
# if block_mod == 'dac':
|
|
||||||
# f.write(f'impl_dac!({name});')
|
|
||||||
# if 'dac_out1' in peri:
|
|
||||||
# pin = peri['dac_out1']
|
|
||||||
# f.write(f'impl_dac_pin!({name}, 1, {pin});')
|
|
||||||
# if 'dac_out2' in peri:
|
|
||||||
# pin = peri['dac_out2']
|
|
||||||
# f.write(f'impl_dac_pin!({name}, 2, {pin});')
|
|
||||||
#
|
|
||||||
if not custom_singletons:
|
if not custom_singletons:
|
||||||
singletons.append(name)
|
singletons.append(name)
|
||||||
|
|
||||||
f.write(f"embassy_extras::peripherals!({','.join(singletons)});")
|
f.write(f"embassy_extras::peripherals!({','.join(singletons)});")
|
||||||
|
|
||||||
# ========= exti interrupts
|
|
||||||
# f.write(f"impl_exti_irq!({','.join(exti_interrupts)});")
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![macro_use]
|
#![macro_use]
|
||||||
|
|
||||||
#[cfg_attr(sdmmc_v1, path = "v1.rs")]
|
//#[cfg_attr(sdmmc_v1, path = "v1.rs")]
|
||||||
#[cfg_attr(sdmmc_v2, path = "v2.rs")]
|
#[cfg_attr(sdmmc_v2, path = "v2.rs")]
|
||||||
mod _version;
|
mod _version;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ use crate::interrupt::Interrupt;
|
|||||||
use crate::pac;
|
use crate::pac;
|
||||||
use crate::pac::gpio::Gpio;
|
use crate::pac::gpio::Gpio;
|
||||||
use crate::pac::sdmmc::Sdmmc as RegBlock;
|
use crate::pac::sdmmc::Sdmmc as RegBlock;
|
||||||
|
use crate::peripherals;
|
||||||
use crate::time::Hertz;
|
use crate::time::Hertz;
|
||||||
|
|
||||||
/// The signalling scheme used on the SDMMC bus
|
/// The signalling scheme used on the SDMMC bus
|
||||||
@ -1469,12 +1470,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_sdmmc {
|
crate::pac::peripherals!(
|
||||||
($inst:ident) => {
|
(sdmmc, $inst:ident) => {
|
||||||
impl crate::sdmmc::sealed::Instance for peripherals::$inst {
|
impl sealed::Instance for peripherals::$inst {
|
||||||
type Interrupt = crate::interrupt::$inst;
|
type Interrupt = crate::interrupt::$inst;
|
||||||
|
|
||||||
fn inner() -> crate::sdmmc::SdmmcInner {
|
fn inner() -> SdmmcInner {
|
||||||
const INNER: crate::sdmmc::SdmmcInner = crate::sdmmc::SdmmcInner(crate::pac::$inst);
|
const INNER: crate::sdmmc::SdmmcInner = crate::sdmmc::SdmmcInner(crate::pac::$inst);
|
||||||
INNER
|
INNER
|
||||||
}
|
}
|
||||||
@ -1485,19 +1486,55 @@ macro_rules! impl_sdmmc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::sdmmc::Instance for peripherals::$inst {}
|
impl Instance for peripherals::$inst {}
|
||||||
|
};
|
||||||
|
);
|
||||||
|
|
||||||
|
macro_rules! impl_pin {
|
||||||
|
($inst:ident, $pin:ident, $signal:ident, $af:expr) => {
|
||||||
|
impl crate::sdmmc::sealed::$signal<peripherals::$inst> for peripherals::$pin {
|
||||||
|
const AF_NUM: u8 = $af;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::sdmmc::$signal<peripherals::$inst> for peripherals::$pin {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_sdmmc_pin {
|
crate::pac::peripheral_pins!(
|
||||||
($inst:ident, $func:ident, $pin:ident, $num:expr) => {
|
($inst:ident, sdmmc, SDMMC, $pin:ident, CK, $af:expr) => {
|
||||||
impl crate::sdmmc::sealed::$func<peripherals::$inst> for peripherals::$pin {
|
impl_pin!($inst, $pin, CkPin, $af);
|
||||||
const AF_NUM: u8 = $num;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl crate::sdmmc::$func<peripherals::$inst> for peripherals::$pin {}
|
|
||||||
};
|
};
|
||||||
}
|
($inst:ident, sdmmc, SDMMC, $pin:ident, CMD, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, CmdPin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D0, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D0Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D1, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D1Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D2, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D2Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D3, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D3Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D4, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D4Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D5, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D5Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D6, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D6Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D6, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D7Pin, $af);
|
||||||
|
};
|
||||||
|
($inst:ident, sdmmc, SDMMC, $pin:ident, D8, $af:expr) => {
|
||||||
|
impl_pin!($inst, $pin, D8Pin, $af);
|
||||||
|
};
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg(feature = "sdmmc-rs")]
|
#[cfg(feature = "sdmmc-rs")]
|
||||||
mod sdmmc_rs {
|
mod sdmmc_rs {
|
||||||
|
Loading…
Reference in New Issue
Block a user