mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 14:22:33 +00:00
net-enc28j60: fix PHY read unreliable due to missing dummy byte.
This commit is contained in:
parent
4af1cf88d2
commit
253b28deba
@ -361,10 +361,16 @@ where
|
||||
fn _read_control_register(&mut self, register: Register) -> u8 {
|
||||
self.change_bank(register);
|
||||
|
||||
let mut buffer = [Instruction::RCR.opcode() | register.addr(), 0];
|
||||
self.spi.transfer_in_place(&mut buffer).unwrap();
|
||||
|
||||
buffer[1]
|
||||
if register.is_eth_register() {
|
||||
let mut buffer = [Instruction::RCR.opcode() | register.addr(), 0];
|
||||
self.spi.transfer_in_place(&mut buffer).unwrap();
|
||||
buffer[1]
|
||||
} else {
|
||||
// MAC, MII regs need a dummy byte.
|
||||
let mut buffer = [Instruction::RCR.opcode() | register.addr(), 0, 0];
|
||||
self.spi.transfer_in_place(&mut buffer).unwrap();
|
||||
buffer[2]
|
||||
}
|
||||
}
|
||||
|
||||
fn read_phy_register(&mut self, register: phy::Register) -> u16 {
|
||||
@ -379,11 +385,10 @@ where
|
||||
// wait until the read operation finishes
|
||||
while self.read_control_register(bank3::Register::MISTAT) & 0b1 != 0 {}
|
||||
|
||||
let h = self.read_control_register(bank2::Register::MIRDH);
|
||||
let l = self.read_control_register(bank2::Register::MIRDL);
|
||||
|
||||
self.write_control_register(bank2::Register::MICMD, bank2::MICMD::default().miird(0).bits());
|
||||
|
||||
let l = self.read_control_register(bank2::Register::MIRDL);
|
||||
let h = self.read_control_register(bank2::Register::MIRDH);
|
||||
(l as u16) | (h as u16) << 8
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ register!(PHCON2, 0, u16, {
|
||||
});
|
||||
|
||||
register!(PHSTAT2, 0, u16, {
|
||||
// Datasheet says it's bit 10, but it's actually bit 2 ?!?!
|
||||
#[doc = "Link Status bit"]
|
||||
lstat @ 2,
|
||||
lstat @ 10,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user