diff options
| author | Matt Johnston <[email protected]> | 2025-04-04 15:08:05 +0800 |
|---|---|---|
| committer | Matt Johnston <[email protected]> | 2025-04-04 17:41:53 +0800 |
| commit | 6b80f3badaf722309f13accd0e8a7e0f04a837ce (patch) | |
| tree | 12a074a9c1ba6aff348c40f4096cddf275da1918 | |
| parent | e22fe7cbcfbbb68e4ad6ef7914bf8ed952fca8f4 (diff) | |
stm32: xspi: rework switching between ncs1 and ncs2
| -rw-r--r-- | embassy-stm32/build.rs | 24 | ||||
| -rw-r--r-- | embassy-stm32/src/macros.rs | 11 | ||||
| -rw-r--r-- | embassy-stm32/src/xspi/mod.rs | 69 |
3 files changed, 73 insertions, 31 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index fa9e3f953..b4e61878c 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -1123,8 +1123,8 @@ fn main() { | |||
| 1123 | (("xspi", "IO15"), quote!(crate::xspi::D15Pin)), | 1123 | (("xspi", "IO15"), quote!(crate::xspi::D15Pin)), |
| 1124 | (("xspi", "DQS0"), quote!(crate::xspi::DQS0Pin)), | 1124 | (("xspi", "DQS0"), quote!(crate::xspi::DQS0Pin)), |
| 1125 | (("xspi", "DQS1"), quote!(crate::xspi::DQS1Pin)), | 1125 | (("xspi", "DQS1"), quote!(crate::xspi::DQS1Pin)), |
| 1126 | (("xspi", "NCS1"), quote!(crate::xspi::NCS1Pin)), | 1126 | (("xspi", "NCS1"), quote!(crate::xspi::NCSPin)), |
| 1127 | (("xspi", "NCS2"), quote!(crate::xspi::NCS2Pin)), | 1127 | (("xspi", "NCS2"), quote!(crate::xspi::NCSPin)), |
| 1128 | (("xspi", "CLK"), quote!(crate::xspi::CLKPin)), | 1128 | (("xspi", "CLK"), quote!(crate::xspi::CLKPin)), |
| 1129 | (("xspi", "NCLK"), quote!(crate::xspi::NCLKPin)), | 1129 | (("xspi", "NCLK"), quote!(crate::xspi::NCLKPin)), |
| 1130 | (("xspim", "P1_IO0"), quote!(crate::xspi::D0Pin)), | 1130 | (("xspim", "P1_IO0"), quote!(crate::xspi::D0Pin)), |
| @@ -1145,8 +1145,8 @@ fn main() { | |||
| 1145 | (("xspim", "P1_IO15"), quote!(crate::xspi::D15Pin)), | 1145 | (("xspim", "P1_IO15"), quote!(crate::xspi::D15Pin)), |
| 1146 | (("xspim", "P1_DQS0"), quote!(crate::xspi::DQS0Pin)), | 1146 | (("xspim", "P1_DQS0"), quote!(crate::xspi::DQS0Pin)), |
| 1147 | (("xspim", "P1_DQS1"), quote!(crate::xspi::DQS1Pin)), | 1147 | (("xspim", "P1_DQS1"), quote!(crate::xspi::DQS1Pin)), |
| 1148 | (("xspim", "P1_NCS1"), quote!(crate::xspi::NCS1Pin)), | 1148 | (("xspim", "P1_NCS1"), quote!(crate::xspi::NCSPin)), |
| 1149 | (("xspim", "P1_NCS2"), quote!(crate::xspi::NCS2Pin)), | 1149 | (("xspim", "P1_NCS2"), quote!(crate::xspi::NCSPin)), |
| 1150 | (("xspim", "P1_CLK"), quote!(crate::xspi::CLKPin)), | 1150 | (("xspim", "P1_CLK"), quote!(crate::xspi::CLKPin)), |
| 1151 | (("xspim", "P1_NCLK"), quote!(crate::xspi::NCLKPin)), | 1151 | (("xspim", "P1_NCLK"), quote!(crate::xspi::NCLKPin)), |
| 1152 | (("xspim", "P2_IO0"), quote!(crate::xspi::D0Pin)), | 1152 | (("xspim", "P2_IO0"), quote!(crate::xspi::D0Pin)), |
| @@ -1167,8 +1167,8 @@ fn main() { | |||
| 1167 | (("xspim", "P2_IO15"), quote!(crate::xspi::D15Pin)), | 1167 | (("xspim", "P2_IO15"), quote!(crate::xspi::D15Pin)), |
| 1168 | (("xspim", "P2_DQS0"), quote!(crate::xspi::DQS0Pin)), | 1168 | (("xspim", "P2_DQS0"), quote!(crate::xspi::DQS0Pin)), |
| 1169 | (("xspim", "P2_DQS1"), quote!(crate::xspi::DQS1Pin)), | 1169 | (("xspim", "P2_DQS1"), quote!(crate::xspi::DQS1Pin)), |
| 1170 | (("xspim", "P2_NCS1"), quote!(crate::xspi::NCS1Pin)), | 1170 | (("xspim", "P2_NCS1"), quote!(crate::xspi::NCSPin)), |
| 1171 | (("xspim", "P2_NCS2"), quote!(crate::xspi::NCS2Pin)), | 1171 | (("xspim", "P2_NCS2"), quote!(crate::xspi::NCSPin)), |
| 1172 | (("xspim", "P2_CLK"), quote!(crate::xspi::CLKPin)), | 1172 | (("xspim", "P2_CLK"), quote!(crate::xspi::CLKPin)), |
| 1173 | (("xspim", "P2_NCLK"), quote!(crate::xspi::NCLKPin)), | 1173 | (("xspim", "P2_NCLK"), quote!(crate::xspi::NCLKPin)), |
| 1174 | (("hspi", "IO0"), quote!(crate::hspi::D0Pin)), | 1174 | (("hspi", "IO0"), quote!(crate::hspi::D0Pin)), |
| @@ -1274,6 +1274,18 @@ fn main() { | |||
| 1274 | } | 1274 | } |
| 1275 | } | 1275 | } |
| 1276 | 1276 | ||
| 1277 | // XSPI NCS pin to CSSEL mapping | ||
| 1278 | if pin.signal.ends_with("NCS1") { | ||
| 1279 | g.extend(quote! { | ||
| 1280 | sel_trait_impl!(crate::xspi::NCSEither, #peri, #pin_name, 0); | ||
| 1281 | }) | ||
| 1282 | } | ||
| 1283 | if pin.signal.ends_with("NCS2") { | ||
| 1284 | g.extend(quote! { | ||
| 1285 | sel_trait_impl!(crate::xspi::NCSEither, #peri, #pin_name, 1); | ||
| 1286 | }) | ||
| 1287 | } | ||
| 1288 | |||
| 1277 | g.extend(quote! { | 1289 | g.extend(quote! { |
| 1278 | pin_trait_impl!(#tr, #peri, #pin_name, #af); | 1290 | pin_trait_impl!(#tr, #peri, #pin_name, #af); |
| 1279 | }) | 1291 | }) |
diff --git a/embassy-stm32/src/macros.rs b/embassy-stm32/src/macros.rs index 2c181a254..7526bb180 100644 --- a/embassy-stm32/src/macros.rs +++ b/embassy-stm32/src/macros.rs | |||
| @@ -60,6 +60,17 @@ macro_rules! pin_trait_impl { | |||
| 60 | }; | 60 | }; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | #[allow(unused_macros)] | ||
| 64 | macro_rules! sel_trait_impl { | ||
| 65 | (crate::$mod:ident::$trait:ident$(<$mode:ident>)?, $instance:ident, $pin:ident, $sel:expr) => { | ||
| 66 | impl crate::$mod::$trait<crate::peripherals::$instance $(, crate::$mod::$mode)?> for crate::peripherals::$pin { | ||
| 67 | fn sel(&self) -> u8 { | ||
| 68 | $sel | ||
| 69 | } | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | } | ||
| 73 | |||
| 63 | // ==================== | 74 | // ==================== |
| 64 | 75 | ||
| 65 | macro_rules! dma_trait { | 76 | macro_rules! dma_trait { |
diff --git a/embassy-stm32/src/xspi/mod.rs b/embassy-stm32/src/xspi/mod.rs index c315e2320..bc3007fe8 100644 --- a/embassy-stm32/src/xspi/mod.rs +++ b/embassy-stm32/src/xspi/mod.rs | |||
| @@ -175,8 +175,12 @@ pub struct Xspi<'d, T: Instance, M: PeriMode> { | |||
| 175 | d13: Option<Peri<'d, AnyPin>>, | 175 | d13: Option<Peri<'d, AnyPin>>, |
| 176 | d14: Option<Peri<'d, AnyPin>>, | 176 | d14: Option<Peri<'d, AnyPin>>, |
| 177 | d15: Option<Peri<'d, AnyPin>>, | 177 | d15: Option<Peri<'d, AnyPin>>, |
| 178 | ncs1: Option<Peri<'d, AnyPin>>, | 178 | ncs: Option<Peri<'d, AnyPin>>, |
| 179 | ncs2: Option<Peri<'d, AnyPin>>, | 179 | // TODO: allow switching between multiple chips |
| 180 | ncs_alt: Option<Peri<'d, AnyPin>>, | ||
| 181 | // false if ncs == NCS1, true if ncs == NCS2 | ||
| 182 | // (ncs_alt will be the opposite to ncs). | ||
| 183 | _cssel_swap: bool, | ||
| 180 | dqs0: Option<Peri<'d, AnyPin>>, | 184 | dqs0: Option<Peri<'d, AnyPin>>, |
| 181 | dqs1: Option<Peri<'d, AnyPin>>, | 185 | dqs1: Option<Peri<'d, AnyPin>>, |
| 182 | dma: Option<ChannelAndRequest<'d>>, | 186 | dma: Option<ChannelAndRequest<'d>>, |
| @@ -269,8 +273,9 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { | |||
| 269 | d14: Option<Peri<'d, AnyPin>>, | 273 | d14: Option<Peri<'d, AnyPin>>, |
| 270 | d15: Option<Peri<'d, AnyPin>>, | 274 | d15: Option<Peri<'d, AnyPin>>, |
| 271 | clk: Option<Peri<'d, AnyPin>>, | 275 | clk: Option<Peri<'d, AnyPin>>, |
| 272 | ncs1: Option<Peri<'d, AnyPin>>, | 276 | ncs_cssel: u8, |
| 273 | ncs2: Option<Peri<'d, AnyPin>>, | 277 | ncs: Option<Peri<'d, AnyPin>>, |
| 278 | ncs_alt: Option<Peri<'d, AnyPin>>, | ||
| 274 | dqs0: Option<Peri<'d, AnyPin>>, | 279 | dqs0: Option<Peri<'d, AnyPin>>, |
| 275 | dqs1: Option<Peri<'d, AnyPin>>, | 280 | dqs1: Option<Peri<'d, AnyPin>>, |
| 276 | dma: Option<ChannelAndRequest<'d>>, | 281 | dma: Option<ChannelAndRequest<'d>>, |
| @@ -341,11 +346,9 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { | |||
| 341 | T::REGS.cr().modify(|w| { | 346 | T::REGS.cr().modify(|w| { |
| 342 | w.set_dmm(dual_quad); | 347 | w.set_dmm(dual_quad); |
| 343 | 348 | ||
| 344 | // TODO: at the moment only ncs1 seems to get passed in? | 349 | assert!(ncs_alt.is_none(), "ncs_alt TODO"); |
| 345 | // Only one must be selected | 350 | let cssel = if ncs_cssel == 0 { Cssel::B_0X0 } else { Cssel::B_0X1 }; |
| 346 | assert!(!(ncs1.is_some() && ncs2.is_some())); | 351 | w.set_cssel(cssel); |
| 347 | assert!(!(ncs1.is_none() && ncs2.is_none())); | ||
| 348 | w.set_cssel(if ncs1.is_some() { Cssel::B_0X0 } else { Cssel::B_0X1 }); | ||
| 349 | }); | 352 | }); |
| 350 | 353 | ||
| 351 | T::REGS.tcr().modify(|w| { | 354 | T::REGS.tcr().modify(|w| { |
| @@ -384,8 +387,9 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { | |||
| 384 | d13, | 387 | d13, |
| 385 | d14, | 388 | d14, |
| 386 | d15, | 389 | d15, |
| 387 | ncs1, | 390 | ncs, |
| 388 | ncs2, | 391 | ncs_alt, |
| 392 | _cssel_swap: ncs_cssel == 1, | ||
| 389 | dqs0, | 393 | dqs0, |
| 390 | dqs1, | 394 | dqs1, |
| 391 | dma, | 395 | dma, |
| @@ -659,7 +663,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 659 | clk: Peri<'d, impl CLKPin<T>>, | 663 | clk: Peri<'d, impl CLKPin<T>>, |
| 660 | d0: Peri<'d, impl D0Pin<T>>, | 664 | d0: Peri<'d, impl D0Pin<T>>, |
| 661 | d1: Peri<'d, impl D1Pin<T>>, | 665 | d1: Peri<'d, impl D1Pin<T>>, |
| 662 | ncs: Peri<'d, impl NCS1Pin<T>>, | 666 | ncs: Peri<'d, impl NCSEither<T>>, |
| 663 | config: Config, | 667 | config: Config, |
| 664 | ) -> Self { | 668 | ) -> Self { |
| 665 | Self::new_inner( | 669 | Self::new_inner( |
| @@ -681,6 +685,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 681 | None, | 685 | None, |
| 682 | None, | 686 | None, |
| 683 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 687 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 688 | ncs.sel(), | ||
| 684 | new_pin!(ncs, AfType::output(OutputType::OpenDrain, Speed::VeryHigh)), | 689 | new_pin!(ncs, AfType::output(OutputType::OpenDrain, Speed::VeryHigh)), |
| 685 | None, | 690 | None, |
| 686 | None, | 691 | None, |
| @@ -698,7 +703,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 698 | clk: Peri<'d, impl CLKPin<T>>, | 703 | clk: Peri<'d, impl CLKPin<T>>, |
| 699 | d0: Peri<'d, impl D0Pin<T>>, | 704 | d0: Peri<'d, impl D0Pin<T>>, |
| 700 | d1: Peri<'d, impl D1Pin<T>>, | 705 | d1: Peri<'d, impl D1Pin<T>>, |
| 701 | ncs: Peri<'d, impl NCS1Pin<T>>, | 706 | ncs: Peri<'d, impl NCSEither<T>>, |
| 702 | config: Config, | 707 | config: Config, |
| 703 | ) -> Self { | 708 | ) -> Self { |
| 704 | Self::new_inner( | 709 | Self::new_inner( |
| @@ -720,6 +725,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 720 | None, | 725 | None, |
| 721 | None, | 726 | None, |
| 722 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 727 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 728 | ncs.sel(), | ||
| 723 | new_pin!( | 729 | new_pin!( |
| 724 | ncs, | 730 | ncs, |
| 725 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 731 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -742,7 +748,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 742 | d1: Peri<'d, impl D1Pin<T>>, | 748 | d1: Peri<'d, impl D1Pin<T>>, |
| 743 | d2: Peri<'d, impl D2Pin<T>>, | 749 | d2: Peri<'d, impl D2Pin<T>>, |
| 744 | d3: Peri<'d, impl D3Pin<T>>, | 750 | d3: Peri<'d, impl D3Pin<T>>, |
| 745 | ncs: Peri<'d, impl NCS1Pin<T>>, | 751 | ncs: Peri<'d, impl NCSEither<T>>, |
| 746 | config: Config, | 752 | config: Config, |
| 747 | ) -> Self { | 753 | ) -> Self { |
| 748 | Self::new_inner( | 754 | Self::new_inner( |
| @@ -764,6 +770,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 764 | None, | 770 | None, |
| 765 | None, | 771 | None, |
| 766 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 772 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 773 | ncs.sel(), | ||
| 767 | new_pin!( | 774 | new_pin!( |
| 768 | ncs, | 775 | ncs, |
| 769 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 776 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -790,7 +797,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 790 | d5: Peri<'d, impl D5Pin<T>>, | 797 | d5: Peri<'d, impl D5Pin<T>>, |
| 791 | d6: Peri<'d, impl D6Pin<T>>, | 798 | d6: Peri<'d, impl D6Pin<T>>, |
| 792 | d7: Peri<'d, impl D7Pin<T>>, | 799 | d7: Peri<'d, impl D7Pin<T>>, |
| 793 | ncs: Peri<'d, impl NCS1Pin<T>>, | 800 | ncs: Peri<'d, impl NCSEither<T>>, |
| 794 | config: Config, | 801 | config: Config, |
| 795 | ) -> Self { | 802 | ) -> Self { |
| 796 | Self::new_inner( | 803 | Self::new_inner( |
| @@ -812,6 +819,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 812 | None, | 819 | None, |
| 813 | None, | 820 | None, |
| 814 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 821 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 822 | ncs.sel(), | ||
| 815 | new_pin!( | 823 | new_pin!( |
| 816 | ncs, | 824 | ncs, |
| 817 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 825 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -838,7 +846,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 838 | d5: Peri<'d, impl D5Pin<T>>, | 846 | d5: Peri<'d, impl D5Pin<T>>, |
| 839 | d6: Peri<'d, impl D6Pin<T>>, | 847 | d6: Peri<'d, impl D6Pin<T>>, |
| 840 | d7: Peri<'d, impl D7Pin<T>>, | 848 | d7: Peri<'d, impl D7Pin<T>>, |
| 841 | ncs: Peri<'d, impl NCS1Pin<T>>, | 849 | ncs: Peri<'d, impl NCSEither<T>>, |
| 842 | config: Config, | 850 | config: Config, |
| 843 | ) -> Self { | 851 | ) -> Self { |
| 844 | Self::new_inner( | 852 | Self::new_inner( |
| @@ -860,6 +868,7 @@ impl<'d, T: Instance> Xspi<'d, T, Blocking> { | |||
| 860 | None, | 868 | None, |
| 861 | None, | 869 | None, |
| 862 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 870 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 871 | ncs.sel(), | ||
| 863 | new_pin!( | 872 | new_pin!( |
| 864 | ncs, | 873 | ncs, |
| 865 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 874 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -882,7 +891,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 882 | clk: Peri<'d, impl CLKPin<T>>, | 891 | clk: Peri<'d, impl CLKPin<T>>, |
| 883 | d0: Peri<'d, impl D0Pin<T>>, | 892 | d0: Peri<'d, impl D0Pin<T>>, |
| 884 | d1: Peri<'d, impl D1Pin<T>>, | 893 | d1: Peri<'d, impl D1Pin<T>>, |
| 885 | ncs: Peri<'d, impl NCS1Pin<T>>, | 894 | ncs: Peri<'d, impl NCSEither<T>>, |
| 886 | dma: Peri<'d, impl XDma<T>>, | 895 | dma: Peri<'d, impl XDma<T>>, |
| 887 | config: Config, | 896 | config: Config, |
| 888 | ) -> Self { | 897 | ) -> Self { |
| @@ -905,6 +914,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 905 | None, | 914 | None, |
| 906 | None, | 915 | None, |
| 907 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 916 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 917 | ncs.sel(), | ||
| 908 | new_pin!(ncs, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 918 | new_pin!(ncs, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 909 | None, | 919 | None, |
| 910 | None, | 920 | None, |
| @@ -922,7 +932,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 922 | clk: Peri<'d, impl CLKPin<T>>, | 932 | clk: Peri<'d, impl CLKPin<T>>, |
| 923 | d0: Peri<'d, impl D0Pin<T>>, | 933 | d0: Peri<'d, impl D0Pin<T>>, |
| 924 | d1: Peri<'d, impl D1Pin<T>>, | 934 | d1: Peri<'d, impl D1Pin<T>>, |
| 925 | ncs: Peri<'d, impl NCS1Pin<T>>, | 935 | ncs: Peri<'d, impl NCSEither<T>>, |
| 926 | dma: Peri<'d, impl XDma<T>>, | 936 | dma: Peri<'d, impl XDma<T>>, |
| 927 | config: Config, | 937 | config: Config, |
| 928 | ) -> Self { | 938 | ) -> Self { |
| @@ -945,6 +955,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 945 | None, | 955 | None, |
| 946 | None, | 956 | None, |
| 947 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 957 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 958 | ncs.sel(), | ||
| 948 | new_pin!( | 959 | new_pin!( |
| 949 | ncs, | 960 | ncs, |
| 950 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 961 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -967,7 +978,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 967 | d1: Peri<'d, impl D1Pin<T>>, | 978 | d1: Peri<'d, impl D1Pin<T>>, |
| 968 | d2: Peri<'d, impl D2Pin<T>>, | 979 | d2: Peri<'d, impl D2Pin<T>>, |
| 969 | d3: Peri<'d, impl D3Pin<T>>, | 980 | d3: Peri<'d, impl D3Pin<T>>, |
| 970 | ncs: Peri<'d, impl NCS1Pin<T>>, | 981 | ncs: Peri<'d, impl NCSEither<T>>, |
| 971 | dma: Peri<'d, impl XDma<T>>, | 982 | dma: Peri<'d, impl XDma<T>>, |
| 972 | config: Config, | 983 | config: Config, |
| 973 | ) -> Self { | 984 | ) -> Self { |
| @@ -990,6 +1001,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 990 | None, | 1001 | None, |
| 991 | None, | 1002 | None, |
| 992 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 1003 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 1004 | ncs.sel(), | ||
| 993 | new_pin!( | 1005 | new_pin!( |
| 994 | ncs, | 1006 | ncs, |
| 995 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 1007 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -1016,7 +1028,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 1016 | d5: Peri<'d, impl D5Pin<T>>, | 1028 | d5: Peri<'d, impl D5Pin<T>>, |
| 1017 | d6: Peri<'d, impl D6Pin<T>>, | 1029 | d6: Peri<'d, impl D6Pin<T>>, |
| 1018 | d7: Peri<'d, impl D7Pin<T>>, | 1030 | d7: Peri<'d, impl D7Pin<T>>, |
| 1019 | ncs: Peri<'d, impl NCS1Pin<T>>, | 1031 | ncs: Peri<'d, impl NCSEither<T>>, |
| 1020 | dma: Peri<'d, impl XDma<T>>, | 1032 | dma: Peri<'d, impl XDma<T>>, |
| 1021 | config: Config, | 1033 | config: Config, |
| 1022 | ) -> Self { | 1034 | ) -> Self { |
| @@ -1039,6 +1051,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 1039 | None, | 1051 | None, |
| 1040 | None, | 1052 | None, |
| 1041 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 1053 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 1054 | ncs.sel(), | ||
| 1042 | new_pin!( | 1055 | new_pin!( |
| 1043 | ncs, | 1056 | ncs, |
| 1044 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 1057 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -1065,7 +1078,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 1065 | d5: Peri<'d, impl D5Pin<T>>, | 1078 | d5: Peri<'d, impl D5Pin<T>>, |
| 1066 | d6: Peri<'d, impl D6Pin<T>>, | 1079 | d6: Peri<'d, impl D6Pin<T>>, |
| 1067 | d7: Peri<'d, impl D7Pin<T>>, | 1080 | d7: Peri<'d, impl D7Pin<T>>, |
| 1068 | ncs: Peri<'d, impl NCS1Pin<T>>, | 1081 | ncs: Peri<'d, impl NCSEither<T>>, |
| 1069 | dma: Peri<'d, impl XDma<T>>, | 1082 | dma: Peri<'d, impl XDma<T>>, |
| 1070 | config: Config, | 1083 | config: Config, |
| 1071 | ) -> Self { | 1084 | ) -> Self { |
| @@ -1088,6 +1101,7 @@ impl<'d, T: Instance> Xspi<'d, T, Async> { | |||
| 1088 | None, | 1101 | None, |
| 1089 | None, | 1102 | None, |
| 1090 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), | 1103 | new_pin!(clk, AfType::output(OutputType::PushPull, Speed::VeryHigh)), |
| 1104 | ncs.sel(), | ||
| 1091 | new_pin!( | 1105 | new_pin!( |
| 1092 | ncs, | 1106 | ncs, |
| 1093 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) | 1107 | AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) |
| @@ -1262,8 +1276,8 @@ impl<'d, T: Instance, M: PeriMode> Drop for Xspi<'d, T, M> { | |||
| 1262 | self.d13.as_ref().map(|x| x.set_as_disconnected()); | 1276 | self.d13.as_ref().map(|x| x.set_as_disconnected()); |
| 1263 | self.d14.as_ref().map(|x| x.set_as_disconnected()); | 1277 | self.d14.as_ref().map(|x| x.set_as_disconnected()); |
| 1264 | self.d15.as_ref().map(|x| x.set_as_disconnected()); | 1278 | self.d15.as_ref().map(|x| x.set_as_disconnected()); |
| 1265 | self.ncs1.as_ref().map(|x| x.set_as_disconnected()); | 1279 | self.ncs.as_ref().map(|x| x.set_as_disconnected()); |
| 1266 | self.ncs2.as_ref().map(|x| x.set_as_disconnected()); | 1280 | self.ncs_alt.as_ref().map(|x| x.set_as_disconnected()); |
| 1267 | self.dqs0.as_ref().map(|x| x.set_as_disconnected()); | 1281 | self.dqs0.as_ref().map(|x| x.set_as_disconnected()); |
| 1268 | self.dqs1.as_ref().map(|x| x.set_as_disconnected()); | 1282 | self.dqs1.as_ref().map(|x| x.set_as_disconnected()); |
| 1269 | 1283 | ||
| @@ -1320,12 +1334,17 @@ pin_trait!(D14Pin, Instance); | |||
| 1320 | pin_trait!(D15Pin, Instance); | 1334 | pin_trait!(D15Pin, Instance); |
| 1321 | pin_trait!(DQS0Pin, Instance); | 1335 | pin_trait!(DQS0Pin, Instance); |
| 1322 | pin_trait!(DQS1Pin, Instance); | 1336 | pin_trait!(DQS1Pin, Instance); |
| 1323 | pin_trait!(NCS1Pin, Instance); | 1337 | pin_trait!(NCSPin, Instance); |
| 1324 | pin_trait!(NCS2Pin, Instance); | ||
| 1325 | pin_trait!(CLKPin, Instance); | 1338 | pin_trait!(CLKPin, Instance); |
| 1326 | pin_trait!(NCLKPin, Instance); | 1339 | pin_trait!(NCLKPin, Instance); |
| 1327 | dma_trait!(XDma, Instance); | 1340 | dma_trait!(XDma, Instance); |
| 1328 | 1341 | ||
| 1342 | /// Trait for either NCS1 or NCS2 pins | ||
| 1343 | pub trait NCSEither<T: Instance>: NCSPin<T> { | ||
| 1344 | /// Get the CSSEL for this NCS pin | ||
| 1345 | fn sel(&self) -> u8; | ||
| 1346 | } | ||
| 1347 | |||
| 1329 | // Hard-coded the xspi index, for SPIM | 1348 | // Hard-coded the xspi index, for SPIM |
| 1330 | #[cfg(xspim_v1)] | 1349 | #[cfg(xspim_v1)] |
| 1331 | impl SealedXspimInstance for peripherals::XSPI1 { | 1350 | impl SealedXspimInstance for peripherals::XSPI1 { |
