Struct attiny_hal::spi::ChipSelectPin
source · pub struct ChipSelectPin<CSPIN>(/* private fields */);
Expand description
Wrapper for the CS pin
Used to contain the chip-select pin during operation to prevent its mode from being changed from Output. This is necessary because the SPI state machine would otherwise reset itself to SPI slave mode immediately. This wrapper can be used just like an output pin, because it implements all the same traits from embedded-hal.
Implementations§
source§impl<CSPIN> ChipSelectPin<CSPIN>where
CSPIN: PinOps,
impl<CSPIN> ChipSelectPin<CSPIN>where
CSPIN: PinOps,
sourcepub unsafe fn into_pin_unchecked(self) -> Pin<Output, CSPIN>
pub unsafe fn into_pin_unchecked(self) -> Pin<Output, CSPIN>
Convert this ChipSelectPin
into the underlying “real” Pin<>
object.
§Safety
This function is unsafe because the underlying pin can be converted into a non-output mode which would break SPI functionality. The user must ensure the pin is only used in output modes after calling this function.
sourcepub unsafe fn from_pin(pin: Pin<Output, CSPIN>) -> ChipSelectPin<CSPIN>
pub unsafe fn from_pin(pin: Pin<Output, CSPIN>) -> ChipSelectPin<CSPIN>
(Re)create a ChipSelectPin
from a real Pin<>
object.
This function is only meant to be used when the pin was previously moved out of the
ChipSelectPin
using ChipSelectPin::into_pin_unchecked()
.