diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-02-10 21:38:03 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-02-10 21:38:03 +0100 |
| commit | b99ab3d5d9d8fdee135956dcbc2111b00abd1d72 (patch) | |
| tree | 53f3723e24ba49b98f0a792aa9835141ef56729e /embassy-stm32/src/eth/mod.rs | |
| parent | 9d682aa1fae81d9bb56bb41304828144b9a0d4a7 (diff) | |
stm32: Add standard crate-wide macros for pin/dma traits, switch all drivers to use them.
Diffstat (limited to 'embassy-stm32/src/eth/mod.rs')
| -rw-r--r-- | embassy-stm32/src/eth/mod.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/embassy-stm32/src/eth/mod.rs b/embassy-stm32/src/eth/mod.rs index 664c19daa..cf145e393 100644 --- a/embassy-stm32/src/eth/mod.rs +++ b/embassy-stm32/src/eth/mod.rs | |||
| @@ -33,3 +33,58 @@ pub unsafe trait PHY { | |||
| 33 | /// Poll link to see if it is up and FD with 100Mbps | 33 | /// Poll link to see if it is up and FD with 100Mbps |
| 34 | fn poll_link<S: StationManagement>(sm: &mut S) -> bool; | 34 | fn poll_link<S: StationManagement>(sm: &mut S) -> bool; |
| 35 | } | 35 | } |
| 36 | |||
| 37 | pub(crate) mod sealed { | ||
| 38 | pub trait Instance { | ||
| 39 | fn regs() -> crate::pac::eth::Eth; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | pub trait Instance: sealed::Instance + Send + 'static {} | ||
| 44 | |||
| 45 | impl sealed::Instance for crate::peripherals::ETH { | ||
| 46 | fn regs() -> crate::pac::eth::Eth { | ||
| 47 | crate::pac::ETH | ||
| 48 | } | ||
| 49 | } | ||
| 50 | impl Instance for crate::peripherals::ETH {} | ||
| 51 | |||
| 52 | pin_trait!(RefClkPin, Instance); | ||
| 53 | pin_trait!(MDIOPin, Instance); | ||
| 54 | pin_trait!(MDCPin, Instance); | ||
| 55 | pin_trait!(CRSPin, Instance); | ||
| 56 | pin_trait!(RXD0Pin, Instance); | ||
| 57 | pin_trait!(RXD1Pin, Instance); | ||
| 58 | pin_trait!(TXD0Pin, Instance); | ||
| 59 | pin_trait!(TXD1Pin, Instance); | ||
| 60 | pin_trait!(TXEnPin, Instance); | ||
| 61 | |||
| 62 | crate::pac::peripheral_pins!( | ||
| 63 | ($inst:ident, eth, ETH, $pin:ident, REF_CLK, $af:expr) => { | ||
| 64 | pin_trait_impl!(RefClkPin, $inst, $pin, $af); | ||
| 65 | }; | ||
| 66 | ($inst:ident, eth, ETH, $pin:ident, MDIO, $af:expr) => { | ||
| 67 | pin_trait_impl!(MDIOPin, $inst, $pin, $af); | ||
| 68 | }; | ||
| 69 | ($inst:ident, eth, ETH, $pin:ident, MDC, $af:expr) => { | ||
| 70 | pin_trait_impl!(MDCPin, $inst, $pin, $af); | ||
| 71 | }; | ||
| 72 | ($inst:ident, eth, ETH, $pin:ident, CRS_DV, $af:expr) => { | ||
| 73 | pin_trait_impl!(CRSPin, $inst, $pin, $af); | ||
| 74 | }; | ||
| 75 | ($inst:ident, eth, ETH, $pin:ident, RXD0, $af:expr) => { | ||
| 76 | pin_trait_impl!(RXD0Pin, $inst, $pin, $af); | ||
| 77 | }; | ||
| 78 | ($inst:ident, eth, ETH, $pin:ident, RXD1, $af:expr) => { | ||
| 79 | pin_trait_impl!(RXD1Pin, $inst, $pin, $af); | ||
| 80 | }; | ||
| 81 | ($inst:ident, eth, ETH, $pin:ident, TXD0, $af:expr) => { | ||
| 82 | pin_trait_impl!(TXD0Pin, $inst, $pin, $af); | ||
| 83 | }; | ||
| 84 | ($inst:ident, eth, ETH, $pin:ident, TXD1, $af:expr) => { | ||
| 85 | pin_trait_impl!(TXD1Pin, $inst, $pin, $af); | ||
| 86 | }; | ||
| 87 | ($inst:ident, eth, ETH, $pin:ident, TX_EN, $af:expr) => { | ||
| 88 | pin_trait_impl!(TXEnPin, $inst, $pin, $af); | ||
| 89 | }; | ||
| 90 | ); | ||
