aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/eth/mod.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-02-10 21:38:03 +0100
committerDario Nieuwenhuis <[email protected]>2022-02-10 21:38:03 +0100
commitb99ab3d5d9d8fdee135956dcbc2111b00abd1d72 (patch)
tree53f3723e24ba49b98f0a792aa9835141ef56729e /embassy-stm32/src/eth/mod.rs
parent9d682aa1fae81d9bb56bb41304828144b9a0d4a7 (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.rs55
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
37pub(crate) mod sealed {
38 pub trait Instance {
39 fn regs() -> crate::pac::eth::Eth;
40 }
41}
42
43pub trait Instance: sealed::Instance + Send + 'static {}
44
45impl sealed::Instance for crate::peripherals::ETH {
46 fn regs() -> crate::pac::eth::Eth {
47 crate::pac::ETH
48 }
49}
50impl Instance for crate::peripherals::ETH {}
51
52pin_trait!(RefClkPin, Instance);
53pin_trait!(MDIOPin, Instance);
54pin_trait!(MDCPin, Instance);
55pin_trait!(CRSPin, Instance);
56pin_trait!(RXD0Pin, Instance);
57pin_trait!(RXD1Pin, Instance);
58pin_trait!(TXD0Pin, Instance);
59pin_trait!(TXD1Pin, Instance);
60pin_trait!(TXEnPin, Instance);
61
62crate::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);