diff --git a/Cargo.lock b/Cargo.lock index 9a113b3..9d6f57f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "byteorder" version = "1.2.6" @@ -24,7 +26,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "w5500" -version = "0.1.5" +version = "0.2.1" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "embedded-hal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 36675b5..3af94a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "w5500" -version = "0.2.0" +version = "0.2.1" authors = ["Michael Watzko "] repository = "https://github.com/kellerkindt/w5500.git" description = "W5500 IoT Controller implementation. Currently UDP sending and receiving is working. WIP" diff --git a/src/lib.rs b/src/lib.rs index b51ef3f..ce89dad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -417,8 +417,8 @@ impl Udp for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) { { let local_port = w5500.read_u16(socket.at(SocketRegister::LocalPort))?; - let local_port = u16_to_be_bytes(local_port); - let host_port = u16_to_be_bytes(host_port); + let local_port = local_port.to_be_bytes(); + let host_port = host_port.to_be_bytes(); w5500.write_to( socket.at(SocketRegister::LocalPort), @@ -443,7 +443,7 @@ impl Udp for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) { let data_length = data.len() as u16; { - let data_length = u16_to_be_bytes(data_length); + let data_length = data_length.to_be_bytes(); // TODO why write [0x00, 0x00] at TxReadPointer at all? // TODO Is TxWritePointer not sufficient enough? @@ -487,12 +487,6 @@ impl Udp for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) { } -fn u16_to_be_bytes(u16: u16) -> [u8; 2] { - let mut bytes = [0u8; 2]; - BigEndian::write_u16(&mut bytes, u16); - bytes -} - #[repr(u8)] #[derive(Copy, Clone, PartialEq, Debug)] pub enum SocketRegister {