@@ -5,8 +5,12 @@ pub unsafe trait MdioPin {}
5
5
/// MDC pin types.
6
6
pub unsafe trait MdcPin { }
7
7
8
+ /// A trait used for implementing access to SMI
9
+ /// peripherals/functionality
8
10
pub trait StationManagement {
11
+ /// Read an SMI register
9
12
fn read ( & self , phy : u8 , reg : u8 ) -> u16 ;
13
+ /// Write an SMI register
10
14
fn write ( & mut self , phy : u8 , reg : u8 , data : u16 ) ;
11
15
}
12
16
@@ -52,9 +56,10 @@ pub(crate) fn smi_read(iar: &MACMIIAR, dr: &MACMIIDR, phy: u8, reg: u8) -> u16 {
52
56
dr. read ( ) . md ( ) . bits ( )
53
57
}
54
58
55
- /// Station Management Interface with pins and registers borrowed from [`EthernetMAC`].
59
+ /// Station Management Interface
56
60
///
57
- /// Can also be constructed by borrowing from [`ETHERNET_MAC`] and borrowing the pins manually.
61
+ /// Borrows [`MACMIIAR`] and [`MACMIIDR`] from (ETHERNET_MAC)[`crate::stm32::ETHERNET_MAC`], and holds a mutable borrow
62
+ /// to the SMI pins.
58
63
///
59
64
/// Provides access to the MIIM implementation exposed by the MCU's MAC API.
60
65
pub struct Smi < ' eth , ' pins , Mdio , Mdc > {
@@ -69,12 +74,10 @@ where
69
74
Mdio : MdioPin ,
70
75
Mdc : MdcPin ,
71
76
{
72
- /// Read an SMI register
73
77
fn read ( & self , phy : u8 , reg : u8 ) -> u16 {
74
78
smi_read ( & self . macmiiar , & self . macmiidr , phy, reg)
75
79
}
76
80
77
- /// Write an SMI register
78
81
fn write ( & mut self , phy : u8 , reg : u8 , data : u16 ) {
79
82
smi_write ( & self . macmiiar , & self . macmiidr , phy, reg, data)
80
83
}
85
88
Mdio : MdioPin ,
86
89
Mdc : MdcPin ,
87
90
{
88
- /// Create the temporary `Smi` instance.
91
+ /// Create a temporary `Smi` instance.
89
92
///
90
93
/// Temporarily take exclusive access to the MDIO and MDC pins to ensure they are not used
91
94
/// elsewhere for the duration of SMI communication.
@@ -102,11 +105,6 @@ where
102
105
_mdc,
103
106
}
104
107
}
105
-
106
- /// Read an SMI register
107
- pub fn read ( & self , phy : u8 , reg : u8 ) -> u16 {
108
- smi_read ( & self . macmiiar , & self . macmiidr , phy, reg)
109
- }
110
108
}
111
109
112
110
#[ cfg( feature = "stm32f4xx-hal" ) ]
0 commit comments