diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-08-15 14:27:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-08-15 14:27:31 +0200 |
| commit | ea9f887ee168aab502ab595aa460c7c0910ff6b9 (patch) | |
| tree | 8df4203aa5c0407c0d725adf616675220b4f27be /embassy-net-enc28j60/src | |
| parent | f7f75167accd1fb91238b05f30a280bf115baddf (diff) | |
net-enc28j60: add docs, readme.
Diffstat (limited to 'embassy-net-enc28j60/src')
| -rw-r--r-- | embassy-net-enc28j60/src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![doc = include_str!("../README.md")] | 2 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | ||
| 3 | 4 | ||
| 4 | // must go first. | 5 | // must go first. |
| 5 | mod fmt; | 6 | mod fmt; |
| @@ -43,6 +44,7 @@ const _TXND: u16 = 0x1fff; | |||
| 43 | 44 | ||
| 44 | const MTU: usize = 1514; // 1500 IP + 14 ethernet header | 45 | const MTU: usize = 1514; // 1500 IP + 14 ethernet header |
| 45 | 46 | ||
| 47 | /// ENC28J60 embassy-net driver | ||
| 46 | pub struct Enc28j60<S, O> { | 48 | pub struct Enc28j60<S, O> { |
| 47 | mac_addr: [u8; 6], | 49 | mac_addr: [u8; 6], |
| 48 | 50 | ||
| @@ -60,6 +62,10 @@ where | |||
| 60 | S: SpiDevice, | 62 | S: SpiDevice, |
| 61 | O: OutputPin, | 63 | O: OutputPin, |
| 62 | { | 64 | { |
| 65 | /// Create a new ENC28J60 driver instance. | ||
| 66 | /// | ||
| 67 | /// The RST pin is optional. If None, reset will be done with a SPI | ||
| 68 | /// soft reset command, instead of via the RST pin. | ||
| 63 | pub fn new(spi: S, rst: Option<O>, mac_addr: [u8; 6]) -> Self { | 69 | pub fn new(spi: S, rst: Option<O>, mac_addr: [u8; 6]) -> Self { |
| 64 | let mut res = Self { | 70 | let mut res = Self { |
| 65 | mac_addr, | 71 | mac_addr, |
| @@ -300,6 +306,7 @@ where | |||
| 300 | }*/ | 306 | }*/ |
| 301 | } | 307 | } |
| 302 | 308 | ||
| 309 | /// Get whether the link is up | ||
| 303 | pub fn is_link_up(&mut self) -> bool { | 310 | pub fn is_link_up(&mut self) -> bool { |
| 304 | let bits = self.read_phy_register(phy::Register::PHSTAT2); | 311 | let bits = self.read_phy_register(phy::Register::PHSTAT2); |
| 305 | phy::PHSTAT2(bits).lstat() == 1 | 312 | phy::PHSTAT2(bits).lstat() == 1 |
| @@ -659,6 +666,7 @@ where | |||
| 659 | } | 666 | } |
| 660 | } | 667 | } |
| 661 | 668 | ||
| 669 | /// embassy-net RX token. | ||
| 662 | pub struct RxToken<'a> { | 670 | pub struct RxToken<'a> { |
| 663 | buf: &'a mut [u8], | 671 | buf: &'a mut [u8], |
| 664 | } | 672 | } |
| @@ -672,6 +680,7 @@ impl<'a> embassy_net_driver::RxToken for RxToken<'a> { | |||
| 672 | } | 680 | } |
| 673 | } | 681 | } |
| 674 | 682 | ||
| 683 | /// embassy-net TX token. | ||
| 675 | pub struct TxToken<'a, S, O> | 684 | pub struct TxToken<'a, S, O> |
| 676 | where | 685 | where |
| 677 | S: SpiDevice, | 686 | S: SpiDevice, |
