From ea9f887ee168aab502ab595aa460c7c0910ff6b9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 15 Aug 2023 14:27:31 +0200 Subject: [PATCH] net-enc28j60: add docs, readme. --- embassy-net-enc28j60/README.md | 18 ++++++++++++++++++ embassy-net-enc28j60/src/lib.rs | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/embassy-net-enc28j60/README.md b/embassy-net-enc28j60/README.md index e12d240c3..39011ca13 100644 --- a/embassy-net-enc28j60/README.md +++ b/embassy-net-enc28j60/README.md @@ -1 +1,19 @@ # `embassy-net-enc28j60` + +[`embassy-net`](https://crates.io/crates/embassy-net) integration for the Microchip ENC28J60 Ethernet chip. + +Based on [@japaric](https://github.com/japaric)'s [`enc28j60`](https://github.com/japaric/enc28j60) crate. + +## Interoperability + +This crate can run on any executor. + +## License + +This work is licensed under either of + +- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. diff --git a/embassy-net-enc28j60/src/lib.rs b/embassy-net-enc28j60/src/lib.rs index d77dc2c5e..09e77bafd 100644 --- a/embassy-net-enc28j60/src/lib.rs +++ b/embassy-net-enc28j60/src/lib.rs @@ -1,5 +1,6 @@ #![no_std] #![doc = include_str!("../README.md")] +#![warn(missing_docs)] // must go first. mod fmt; @@ -43,6 +44,7 @@ const _TXND: u16 = 0x1fff; const MTU: usize = 1514; // 1500 IP + 14 ethernet header +/// ENC28J60 embassy-net driver pub struct Enc28j60 { mac_addr: [u8; 6], @@ -60,6 +62,10 @@ where S: SpiDevice, O: OutputPin, { + /// Create a new ENC28J60 driver instance. + /// + /// The RST pin is optional. If None, reset will be done with a SPI + /// soft reset command, instead of via the RST pin. pub fn new(spi: S, rst: Option, mac_addr: [u8; 6]) -> Self { let mut res = Self { mac_addr, @@ -300,6 +306,7 @@ where }*/ } + /// Get whether the link is up pub fn is_link_up(&mut self) -> bool { let bits = self.read_phy_register(phy::Register::PHSTAT2); phy::PHSTAT2(bits).lstat() == 1 @@ -659,6 +666,7 @@ where } } +/// embassy-net RX token. pub struct RxToken<'a> { buf: &'a mut [u8], } @@ -672,6 +680,7 @@ impl<'a> embassy_net_driver::RxToken for RxToken<'a> { } } +/// embassy-net TX token. pub struct TxToken<'a, S, O> where S: SpiDevice,