support QSPI BK2
This commit is contained in:
parent
a1036e111e
commit
729338875c
@ -719,18 +719,24 @@ fn main() {
|
||||
(("sdmmc", "D6"), quote!(crate::sdmmc::D6Pin)),
|
||||
(("sdmmc", "D6"), quote!(crate::sdmmc::D7Pin)),
|
||||
(("sdmmc", "D8"), quote!(crate::sdmmc::D8Pin)),
|
||||
(("quadspi", "BK1_IO0"), quote!(crate::qspi::D0Pin)),
|
||||
(("quadspi", "BK1_IO1"), quote!(crate::qspi::D1Pin)),
|
||||
(("quadspi", "BK1_IO2"), quote!(crate::qspi::D2Pin)),
|
||||
(("quadspi", "BK1_IO3"), quote!(crate::qspi::D3Pin)),
|
||||
(("quadspi", "BK1_IO0"), quote!(crate::qspi::BK1D0Pin)),
|
||||
(("quadspi", "BK1_IO1"), quote!(crate::qspi::BK1D1Pin)),
|
||||
(("quadspi", "BK1_IO2"), quote!(crate::qspi::BK1D2Pin)),
|
||||
(("quadspi", "BK1_IO3"), quote!(crate::qspi::BK1D3Pin)),
|
||||
(("quadspi", "BK1_NCS"), quote!(crate::qspi::BK1NSSPin)),
|
||||
(("quadspi", "BK2_IO0"), quote!(crate::qspi::BK2D0Pin)),
|
||||
(("quadspi", "BK2_IO1"), quote!(crate::qspi::BK2D1Pin)),
|
||||
(("quadspi", "BK2_IO2"), quote!(crate::qspi::BK2D2Pin)),
|
||||
(("quadspi", "BK2_IO3"), quote!(crate::qspi::BK2D3Pin)),
|
||||
(("quadspi", "BK2_NCS"), quote!(crate::qspi::BK2NSSPin)),
|
||||
(("quadspi", "CLK"), quote!(crate::qspi::SckPin)),
|
||||
(("quadspi", "BK1_NCS"), quote!(crate::qspi::NSSPin)),
|
||||
].into();
|
||||
|
||||
for p in METADATA.peripherals {
|
||||
if let Some(regs) = &p.registers {
|
||||
for pin in p.pins {
|
||||
let key = (regs.kind, pin.signal);
|
||||
eprintln!("key: {:#?}", &key);
|
||||
if let Some(tr) = signals.get(&key) {
|
||||
let mut peri = format_ident!("{}", p.name);
|
||||
|
||||
|
@ -83,14 +83,53 @@ pub struct Qspi<'d, T: Instance, Dma> {
|
||||
}
|
||||
|
||||
impl<'d, T: Instance, Dma> Qspi<'d, T, Dma> {
|
||||
pub fn new(
|
||||
pub fn new_bk1(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
d0: impl Peripheral<P = impl D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl D2Pin<T>> + 'd,
|
||||
d3: impl Peripheral<P = impl D3Pin<T>> + 'd,
|
||||
d0: impl Peripheral<P = impl BK1D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl BK1D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl BK1D2Pin<T>> + 'd,
|
||||
d3: impl Peripheral<P = impl BK1D3Pin<T>> + 'd,
|
||||
sck: impl Peripheral<P = impl SckPin<T>> + 'd,
|
||||
nss: impl Peripheral<P = impl NSSPin<T>> + 'd,
|
||||
nss: impl Peripheral<P = impl BK1NSSPin<T>> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
into_ref!(peri, d0, d1, d2, d3, sck, nss);
|
||||
|
||||
sck.set_as_af(sck.af_num(), AFType::OutputPushPull);
|
||||
sck.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
nss.set_as_af(nss.af_num(), AFType::OutputPushPull);
|
||||
nss.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
d0.set_as_af(d0.af_num(), AFType::OutputPushPull);
|
||||
d0.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
d1.set_as_af(d1.af_num(), AFType::OutputPushPull);
|
||||
d1.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
d2.set_as_af(d2.af_num(), AFType::OutputPushPull);
|
||||
d2.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
d3.set_as_af(d3.af_num(), AFType::OutputPushPull);
|
||||
d3.set_speed(crate::gpio::Speed::VeryHigh);
|
||||
|
||||
Self::new_inner(
|
||||
peri,
|
||||
Some(d0.map_into()),
|
||||
Some(d1.map_into()),
|
||||
Some(d2.map_into()),
|
||||
Some(d3.map_into()),
|
||||
Some(sck.map_into()),
|
||||
Some(nss.map_into()),
|
||||
dma,
|
||||
config,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_bk2(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
d0: impl Peripheral<P = impl BK2D0Pin<T>> + 'd,
|
||||
d1: impl Peripheral<P = impl BK2D1Pin<T>> + 'd,
|
||||
d2: impl Peripheral<P = impl BK2D2Pin<T>> + 'd,
|
||||
d3: impl Peripheral<P = impl BK2D3Pin<T>> + 'd,
|
||||
sck: impl Peripheral<P = impl SckPin<T>> + 'd,
|
||||
nss: impl Peripheral<P = impl BK2NSSPin<T>> + 'd,
|
||||
dma: impl Peripheral<P = Dma> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
@ -313,11 +352,17 @@ pub(crate) mod sealed {
|
||||
pub trait Instance: Peripheral<P = Self> + sealed::Instance + RccPeripheral {}
|
||||
|
||||
pin_trait!(SckPin, Instance);
|
||||
pin_trait!(D0Pin, Instance);
|
||||
pin_trait!(D1Pin, Instance);
|
||||
pin_trait!(D2Pin, Instance);
|
||||
pin_trait!(D3Pin, Instance);
|
||||
pin_trait!(NSSPin, Instance);
|
||||
pin_trait!(BK1D0Pin, Instance);
|
||||
pin_trait!(BK1D1Pin, Instance);
|
||||
pin_trait!(BK1D2Pin, Instance);
|
||||
pin_trait!(BK1D3Pin, Instance);
|
||||
pin_trait!(BK1NSSPin, Instance);
|
||||
|
||||
pin_trait!(BK2D0Pin, Instance);
|
||||
pin_trait!(BK2D1Pin, Instance);
|
||||
pin_trait!(BK2D2Pin, Instance);
|
||||
pin_trait!(BK2D3Pin, Instance);
|
||||
pin_trait!(BK2NSSPin, Instance);
|
||||
|
||||
dma_trait!(QuadDma, Instance);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user