embassy_stm32_plus/builder/eth/
phy.rs1use embassy_stm32::eth::{PacketQueue, PHY};
2use embassy_stm32::eth::generic_smi::GenericSMI;
3
4pub struct EthPhy<const TX: usize, const RX: usize, P: PHY> {
6 pub queue: &'static mut PacketQueue<TX, RX>,
8 pub phy: P,
10 pub mac_addr: [u8; 6],
12}
13
14impl<const TX: usize, const RX: usize, P: PHY> EthPhy<TX, RX, P> {
16 #[inline]
18 pub fn new(queue: &'static mut PacketQueue<TX, RX>, phy: P, mac_addr: [u8; 6]) -> Self {
19 Self { queue, phy, mac_addr }
20 }
21
22 #[inline]
24 pub fn from_queue_phy(queue: &'static mut PacketQueue<TX, RX>, phy: P) -> Self {
25 Self::new(queue, phy, [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF])
26 }
27
28 #[inline]
30 pub fn set_mac_addr(mut self, mac_addr: [u8; 6]) -> Self {
31 self.mac_addr = mac_addr;
32 self
33 }
34}
35
36impl<const TX: usize, const RX: usize> EthPhy<TX, RX, GenericSMI> {
38 #[inline]
40 pub fn from_queue(queue: &'static mut PacketQueue<TX, RX>) -> Self {
41 Self::new(queue, GenericSMI::new(0), [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF])
42 }
43}