mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
net-enc28j60: add docs, readme.
This commit is contained in:
parent
f7f75167ac
commit
ea9f887ee1
@ -1 +1,19 @@
|
|||||||
# `embassy-net-enc28j60`
|
# `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.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
// must go first.
|
// must go first.
|
||||||
mod fmt;
|
mod fmt;
|
||||||
@ -43,6 +44,7 @@ const _TXND: u16 = 0x1fff;
|
|||||||
|
|
||||||
const MTU: usize = 1514; // 1500 IP + 14 ethernet header
|
const MTU: usize = 1514; // 1500 IP + 14 ethernet header
|
||||||
|
|
||||||
|
/// ENC28J60 embassy-net driver
|
||||||
pub struct Enc28j60<S, O> {
|
pub struct Enc28j60<S, O> {
|
||||||
mac_addr: [u8; 6],
|
mac_addr: [u8; 6],
|
||||||
|
|
||||||
@ -60,6 +62,10 @@ where
|
|||||||
S: SpiDevice,
|
S: SpiDevice,
|
||||||
O: OutputPin,
|
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<O>, mac_addr: [u8; 6]) -> Self {
|
pub fn new(spi: S, rst: Option<O>, mac_addr: [u8; 6]) -> Self {
|
||||||
let mut res = Self {
|
let mut res = Self {
|
||||||
mac_addr,
|
mac_addr,
|
||||||
@ -300,6 +306,7 @@ where
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get whether the link is up
|
||||||
pub fn is_link_up(&mut self) -> bool {
|
pub fn is_link_up(&mut self) -> bool {
|
||||||
let bits = self.read_phy_register(phy::Register::PHSTAT2);
|
let bits = self.read_phy_register(phy::Register::PHSTAT2);
|
||||||
phy::PHSTAT2(bits).lstat() == 1
|
phy::PHSTAT2(bits).lstat() == 1
|
||||||
@ -659,6 +666,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// embassy-net RX token.
|
||||||
pub struct RxToken<'a> {
|
pub struct RxToken<'a> {
|
||||||
buf: &'a mut [u8],
|
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>
|
pub struct TxToken<'a, S, O>
|
||||||
where
|
where
|
||||||
S: SpiDevice,
|
S: SpiDevice,
|
||||||
|
Loading…
Reference in New Issue
Block a user