Added bus model and InactiveW5500 state
This commit is contained in:
parent
03e30ef699
commit
a43f86d744
7 changed files with 130 additions and 40 deletions
|
|
@ -1,19 +1,30 @@
|
|||
use embedded_hal::spi::FullDuplex;
|
||||
|
||||
use crate::bus::Bus;
|
||||
use crate::bus::{ActiveBus, Bus};
|
||||
|
||||
pub struct ThreeWire {}
|
||||
|
||||
impl ThreeWire {
|
||||
pub fn new() -> Self {
|
||||
Self { }
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Spi: FullDuplex<u8>> Bus<Spi> for ThreeWire {
|
||||
impl Bus for ThreeWire {}
|
||||
|
||||
impl ThreeWire {
|
||||
pub fn activate<Spi: FullDuplex<u8>>(self, spi: Spi) -> ActiveThreeWire<Spi> {
|
||||
ActiveThreeWire { spi }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ActiveThreeWire<Spi: FullDuplex<u8>> {
|
||||
spi: Spi,
|
||||
}
|
||||
|
||||
impl<Spi: FullDuplex<u8>> ActiveBus for ActiveThreeWire<Spi> {
|
||||
type Error = Spi::Error;
|
||||
fn transfer_frame<'a, 'b>(
|
||||
spi: &'b mut Spi,
|
||||
fn transfer_frame<'a>(
|
||||
address_phase: [u8; 2],
|
||||
control_phase: u8,
|
||||
data_phase: &'a mut [u8],
|
||||
|
|
@ -22,3 +33,9 @@ impl<Spi: FullDuplex<u8>> Bus<Spi> for ThreeWire {
|
|||
Ok(data_phase)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Spi: FullDuplex<u8>> ActiveThreeWire<Spi> {
|
||||
pub fn deactivate(self) -> (ThreeWire, Spi) {
|
||||
(ThreeWire::new(), self.spi)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue