Skip to main content

ublox_core/interface/
spi.rs

1use embedded_hal as hal;
2use hal::digital::v2::OutputPin;
3
4use super::DeviceInterface;
5use crate::Error;
6use shufflebuf::ShuffleBuf;
7
8/// This encapsulates the SPI peripheral and associated pins such as:
9/// - CSN: The chip select pin
10pub struct SpiInterface<SPI, CSN> {
11    /// the serial port to use when communicating
12    _spi: SPI,
13    /// the Chip Select pin (GPIO output) to use when communicating
14    _csn: CSN,
15    _shuffler: ShuffleBuf,
16}
17
18impl<SPI, CSN, CommE, PinE> DeviceInterface for SpiInterface<SPI, CSN>
19where
20    SPI: hal::blocking::spi::Write<u8, Error = CommE>
21        + hal::blocking::spi::Transfer<u8, Error = CommE>,
22    CSN: OutputPin<Error = PinE>,
23{
24    type InterfaceError = Error<CommE>;
25
26    fn fill(&mut self) -> usize {
27        // See: 11.6.3 Back-To-Back Read and Write Access
28        unimplemented!()
29    }
30
31    fn read(&mut self) -> Result<u8, Self::InterfaceError> {
32        unimplemented!()
33    }
34
35    fn read_many(
36        &mut self,
37        _buffer: &mut [u8],
38    ) -> Result<usize, Self::InterfaceError> {
39        unimplemented!()
40    }
41}