Began skeleton of new UninitializedW5500 struct and Bus trait/impls
This commit is contained in:
parent
2b82c7f179
commit
03e30ef699
6 changed files with 1019 additions and 976 deletions
39
src/bus/four_wire.rs
Normal file
39
src/bus/four_wire.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use embedded_hal::digital::v2::OutputPin;
|
||||
use embedded_hal::spi::FullDuplex;
|
||||
|
||||
use crate::bus::Bus;
|
||||
|
||||
pub struct FourWire<ChipSelect: OutputPin> {
|
||||
cs: ChipSelect
|
||||
}
|
||||
|
||||
impl<ChipSelect: OutputPin>
|
||||
FourWire<ChipSelect>
|
||||
{
|
||||
pub fn new(cs: ChipSelect) -> Self {
|
||||
Self { cs }
|
||||
}
|
||||
pub fn release(self) -> ChipSelect {
|
||||
self.cs
|
||||
}
|
||||
}
|
||||
|
||||
impl<Spi: FullDuplex<u8>, ChipSelect: OutputPin> Bus<Spi>
|
||||
for FourWire<ChipSelect>
|
||||
{
|
||||
type Error = FourWireError<Spi::Error, ChipSelect::Error>;
|
||||
fn transfer_frame<'a, 'b>(
|
||||
spi: &'b mut Spi,
|
||||
address_phase: [u8; 2],
|
||||
control_phase: u8,
|
||||
data_phase: &'a mut [u8],
|
||||
) -> Result<&'a mut [u8], nb::Error<Self::Error>> {
|
||||
// TODO implement transfer
|
||||
Ok(data_phase)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum FourWireError<SpiError, ChipSelectError> {
|
||||
SpiError(SpiError),
|
||||
ChipSelectError(ChipSelectError),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue