net-enc28j60: fix PHY read unreliable due to missing dummy byte.
This commit is contained in:
parent
4af1cf88d2
commit
253b28deba
2 changed files with 13 additions and 9 deletions
|
@ -361,10 +361,16 @@ where
|
|||
fn _read_control_register(&mut self, register: Register) -> u8 {
|
||||
self.change_bank(register);
|
||||
|
||||
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 a new issue