Skip to content

Commit cb609ab

Browse files
committed
make Serial generic over the number of data bits
1 parent 5295697 commit cb609ab

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,10 @@ pub enum Direction {
739739
}
740740

741741
/// Serial interface
742-
pub trait Serial {
742+
///
743+
/// Some serial interfaces support different data sizes (8 bits, 9 bits, etc.);
744+
/// This can be encoded in this trait via the `Word` type parameter.
745+
pub trait Serial<Word> {
743746
/// Serial interface error
744747
///
745748
/// Possible errors
@@ -748,11 +751,11 @@ pub trait Serial {
748751
/// not read in a timely manner
749752
type Error;
750753

751-
/// Reads a single byte from the serial interface
752-
fn read(&self) -> nb::Result<u8, Self::Error>;
754+
/// Reads a single word from the serial interface
755+
fn read(&self) -> nb::Result<Word, Self::Error>;
753756

754-
/// Writes a single byte to the serial interface
755-
fn write(&self, byte: u8) -> nb::Result<(), Self::Error>;
757+
/// Writes a single word to the serial interface
758+
fn write(&self, word: Word) -> nb::Result<(), Self::Error>;
756759
}
757760

758761
/// Serial Peripheral Interface (full duplex master mode)

0 commit comments

Comments
 (0)