Add Device::deactivate and InactiveDevice::activate
This commit is contained in:
parent
050fc4c1ba
commit
10bbe99582
2 changed files with 41 additions and 17 deletions
|
|
@ -75,4 +75,29 @@ impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
|
||||||
pub fn release(self) -> (SpiBus, HostImpl) {
|
pub fn release(self) -> (SpiBus, HostImpl) {
|
||||||
(self.bus, self.host)
|
(self.bus, self.host)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn deactivate(self) -> (SpiBus, InactiveDevice<HostImpl>) {
|
||||||
|
(
|
||||||
|
self.bus,
|
||||||
|
InactiveDevice {
|
||||||
|
host: self.host,
|
||||||
|
sockets: self.sockets,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct InactiveDevice<HostImpl: Host> {
|
||||||
|
host: HostImpl,
|
||||||
|
sockets: [u8; 1],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<HostImpl: Host> InactiveDevice<HostImpl> {
|
||||||
|
pub fn activate<SpiBus: Bus>(self, bus: SpiBus) -> Device<SpiBus, HostImpl> {
|
||||||
|
Device {
|
||||||
|
bus,
|
||||||
|
host: self.host,
|
||||||
|
sockets: self.sockets,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
33
src/lib.rs
33
src/lib.rs
|
|
@ -1,7 +1,22 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
#![deny(broken_intra_doc_links)]
|
#![deny(broken_intra_doc_links)]
|
||||||
#[macro_use(block)]
|
|
||||||
|
pub mod bus;
|
||||||
|
mod device;
|
||||||
|
mod host;
|
||||||
|
pub mod net;
|
||||||
|
pub mod register;
|
||||||
|
mod socket;
|
||||||
|
pub mod udp;
|
||||||
|
mod uninitialized_device;
|
||||||
|
|
||||||
|
pub use device::{Device, InactiveDevice};
|
||||||
|
pub use host::{Dhcp, HostConfig, Manual};
|
||||||
|
pub use net::MacAddress;
|
||||||
|
pub use uninitialized_device::UninitializedDevice;
|
||||||
|
|
||||||
|
// TODO add better docs to all public items, add unit tests.
|
||||||
|
|
||||||
/// Settings for wake on LAN. Allows the W5500 to optionally emit an interrupt upon receiving a packet
|
/// Settings for wake on LAN. Allows the W5500 to optionally emit an interrupt upon receiving a packet
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
|
@ -53,19 +68,3 @@ impl Default for Mode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add better docs to all public items, add unit tests.
|
|
||||||
|
|
||||||
pub mod bus;
|
|
||||||
mod device;
|
|
||||||
mod host;
|
|
||||||
pub mod net;
|
|
||||||
pub mod register;
|
|
||||||
mod socket;
|
|
||||||
mod udp;
|
|
||||||
mod uninitialized_device;
|
|
||||||
|
|
||||||
pub use device::Device;
|
|
||||||
pub use host::{Dhcp, HostConfig, Manual};
|
|
||||||
pub use net::MacAddress;
|
|
||||||
pub use uninitialized_device::UninitializedDevice;
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue