1
1
//! An abstraction layer for ethernet periperhals embedded in STM32 processors.
2
2
//!
3
- //! For initialisation, see [`new`], and [`new_owned_smi `]
3
+ //! For initialisation, see [`new`], and [`new_with_smi_pins `]
4
4
#![ no_std]
5
5
6
+ use mac:: EthernetMACWithSmi ;
6
7
/// Re-export
7
8
#[ cfg( feature = "stm32f7xx-hal" ) ]
8
9
pub use stm32f7xx_hal as hal;
@@ -74,6 +75,8 @@ mod consts {
74
75
use self :: consts:: * ;
75
76
76
77
/// HCLK must be at least 25MHz to use the ethernet peripheral.
78
+ /// This (empty) struct is returned to indicate that it is not set
79
+ /// correctly
77
80
#[ derive( Debug ) ]
78
81
pub struct WrongClock ;
79
82
@@ -103,7 +106,7 @@ pub fn new<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1>(
103
106
tx_buffer : & ' tx mut [ TxRingEntry ] ,
104
107
clocks : Clocks ,
105
108
pins : EthPins < REFCLK , CRS , TXEN , TXD0 , TXD1 , RXD0 , RXD1 > ,
106
- ) -> Result < ( EthernetDMA < ' rx , ' tx > , EthernetMAC < mac :: BorrowedSmi > ) , WrongClock >
109
+ ) -> Result < ( EthernetDMA < ' rx , ' tx > , EthernetMAC ) , WrongClock >
107
110
where
108
111
REFCLK : RmiiRefClk + AlternateVeryHighSpeed ,
109
112
CRS : RmiiCrsDv + AlternateVeryHighSpeed ,
@@ -115,7 +118,7 @@ where
115
118
{
116
119
pins. setup_pins ( ) ;
117
120
118
- let eth_mac = EthernetMAC :: < mac :: BorrowedSmi > :: new ( eth_mac) ;
121
+ let eth_mac = EthernetMAC :: new ( eth_mac) ;
119
122
120
123
unsafe { new_unchecked ( eth_mac, eth_mmc, eth_dma, rx_buffer, tx_buffer, clocks) }
121
124
}
@@ -139,7 +142,7 @@ where
139
142
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
140
143
/// usually not accessible.
141
144
/// - HCLK must be at least 25 MHz.
142
- pub fn new_owned_smi < ' rx , ' tx , REFCLK , CRS , TXEN , TXD0 , TXD1 , RXD0 , RXD1 , MDIO , MDC > (
145
+ pub fn new_with_smi < ' rx , ' tx , REFCLK , CRS , TXEN , TXD0 , TXD1 , RXD0 , RXD1 , MDIO , MDC > (
143
146
eth_mac : ETHERNET_MAC ,
144
147
eth_mmc : ETHERNET_MMC ,
145
148
eth_dma : ETHERNET_DMA ,
@@ -149,13 +152,7 @@ pub fn new_owned_smi<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1, MDIO,
149
152
pins : EthPins < REFCLK , CRS , TXEN , TXD0 , TXD1 , RXD0 , RXD1 > ,
150
153
mdio : MDIO ,
151
154
mdc : MDC ,
152
- ) -> Result <
153
- (
154
- EthernetDMA < ' rx , ' tx > ,
155
- EthernetMAC < crate :: mac:: OwnedSmi < MDIO , MDC > > ,
156
- ) ,
157
- WrongClock ,
158
- >
155
+ ) -> Result < ( EthernetDMA < ' rx , ' tx > , EthernetMACWithSmi < MDIO , MDC > ) , WrongClock >
159
156
where
160
157
REFCLK : RmiiRefClk + AlternateVeryHighSpeed ,
161
158
CRS : RmiiCrsDv + AlternateVeryHighSpeed ,
@@ -169,9 +166,10 @@ where
169
166
{
170
167
pins. setup_pins ( ) ;
171
168
172
- let eth_mac = EthernetMAC :: < mac :: OwnedSmi < MDIO , MDC > > :: new ( eth_mac, mdio , mdc ) ;
169
+ let eth_mac = EthernetMAC :: new ( eth_mac) ;
173
170
174
171
unsafe { new_unchecked ( eth_mac, eth_mmc, eth_dma, rx_buffer, tx_buffer, clocks) }
172
+ . map ( |( dma, mac) | ( dma, mac. with_smi ( mdio, mdc) ) )
175
173
}
176
174
177
175
/// Create and initialise the ethernet driver (without GPIO configuration and validation).
@@ -186,14 +184,14 @@ where
186
184
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
187
185
/// usually not accessible.
188
186
/// - HCLK must be at least 25MHz.
189
- pub unsafe fn new_unchecked < ' rx , ' tx , Smi > (
190
- eth_mac_in : EthernetMAC < Smi > ,
187
+ pub unsafe fn new_unchecked < ' rx , ' tx > (
188
+ eth_mac_in : EthernetMAC ,
191
189
eth_mmc : ETHERNET_MMC ,
192
190
eth_dma : ETHERNET_DMA ,
193
191
rx_buffer : & ' rx mut [ RxRingEntry ] ,
194
192
tx_buffer : & ' tx mut [ TxRingEntry ] ,
195
193
clocks : Clocks ,
196
- ) -> Result < ( EthernetDMA < ' rx , ' tx > , EthernetMAC < Smi > ) , WrongClock > {
194
+ ) -> Result < ( EthernetDMA < ' rx , ' tx > , EthernetMAC ) , WrongClock > {
197
195
setup:: setup ( ) ;
198
196
199
197
let eth_mac = & eth_mac_in. eth_mac ;
0 commit comments