33use super :: ErrorType ;
44
55/// Blocking transfer with separate buffers
6- pub trait Transfer < W = u8 > : ErrorType {
6+ pub trait Transfer < Word = u8 > : ErrorType {
77 /// Writes and reads simultaneously. `write` is written to the slave on MOSI and
88 /// words received on MISO are stored in `read`.
99 ///
@@ -12,68 +12,68 @@ pub trait Transfer<W = u8>: ErrorType {
1212 /// incoming words after `read` has been filled will be discarded. If `write` is shorter,
1313 /// the value of words sent in MOSI after all `write` has been sent is implementation-defined,
1414 /// typically `0x00`, `0xFF`, or configurable.
15- fn transfer ( & mut self , read : & mut [ W ] , write : & [ W ] ) -> Result < ( ) , Self :: Error > ;
15+ fn transfer ( & mut self , read : & mut [ Word ] , write : & [ Word ] ) -> Result < ( ) , Self :: Error > ;
1616}
1717
18- impl < T : Transfer < W > , W : Copy > Transfer < W > for & mut T {
19- fn transfer ( & mut self , read : & mut [ W ] , write : & [ W ] ) -> Result < ( ) , Self :: Error > {
18+ impl < T : Transfer < Word > , Word : Copy > Transfer < Word > for & mut T {
19+ fn transfer ( & mut self , read : & mut [ Word ] , write : & [ Word ] ) -> Result < ( ) , Self :: Error > {
2020 T :: transfer ( self , read, write)
2121 }
2222}
2323
2424/// Blocking transfer with single buffer (in-place)
25- pub trait TransferInplace < W : Copy = u8 > : ErrorType {
25+ pub trait TransferInplace < Word : Copy = u8 > : ErrorType {
2626 /// Writes and reads simultaneously. The contents of `words` are
2727 /// written to the slave, and the received words are stored into the same
2828 /// `words` buffer, overwriting it.
29- fn transfer_inplace ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
29+ fn transfer_inplace ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > ;
3030}
3131
32- impl < T : TransferInplace < W > , W : Copy > TransferInplace < W > for & mut T {
33- fn transfer_inplace ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
32+ impl < T : TransferInplace < Word > , Word : Copy > TransferInplace < Word > for & mut T {
33+ fn transfer_inplace ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
3434 T :: transfer_inplace ( self , words)
3535 }
3636}
3737
3838/// Blocking read
39- pub trait Read < W : Copy = u8 > : ErrorType {
39+ pub trait Read < Word : Copy = u8 > : ErrorType {
4040 /// Reads `words` from the slave.
4141 ///
4242 /// The word value sent on MOSI during reading is implementation-defined,
4343 /// typically `0x00`, `0xFF`, or configurable.
44- fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
44+ fn read ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > ;
4545}
4646
47- impl < T : Read < W > , W : Copy > Read < W > for & mut T {
48- fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
47+ impl < T : Read < Word > , Word : Copy > Read < Word > for & mut T {
48+ fn read ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
4949 T :: read ( self , words)
5050 }
5151}
5252
5353/// Blocking write
54- pub trait Write < W : Copy = u8 > : ErrorType {
54+ pub trait Write < Word : Copy = u8 > : ErrorType {
5555 /// Writes `words` to the slave, ignoring all the incoming words
56- fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > ;
56+ fn write ( & mut self , words : & [ Word ] ) -> Result < ( ) , Self :: Error > ;
5757}
5858
59- impl < T : Write < W > , W : Copy > Write < W > for & mut T {
60- fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > {
59+ impl < T : Write < Word > , Word : Copy > Write < Word > for & mut T {
60+ fn write ( & mut self , words : & [ Word ] ) -> Result < ( ) , Self :: Error > {
6161 T :: write ( self , words)
6262 }
6363}
6464
6565/// Blocking write (iterator version)
66- pub trait WriteIter < W : Copy = u8 > : ErrorType {
66+ pub trait WriteIter < Word : Copy = u8 > : ErrorType {
6767 /// Writes `words` to the slave, ignoring all the incoming words
6868 fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
6969 where
70- WI : IntoIterator < Item = W > ;
70+ WI : IntoIterator < Item = Word > ;
7171}
7272
73- impl < T : WriteIter < W > , W : Copy > WriteIter < W > for & mut T {
73+ impl < T : WriteIter < Word > , Word : Copy > WriteIter < Word > for & mut T {
7474 fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
7575 where
76- WI : IntoIterator < Item = W > ,
76+ WI : IntoIterator < Item = Word > ,
7777 {
7878 T :: write_iter ( self , words)
7979 }
@@ -83,26 +83,26 @@ impl<T: WriteIter<W>, W: Copy> WriteIter<W> for &mut T {
8383///
8484/// This allows composition of SPI operations into a single bus transaction
8585#[ derive( Debug , PartialEq ) ]
86- pub enum Operation < ' a , W : ' static + Copy = u8 > {
86+ pub enum Operation < ' a , Word : ' static + Copy = u8 > {
8787 /// Read data into the provided buffer.
88- Read ( & ' a mut [ W ] ) ,
88+ Read ( & ' a mut [ Word ] ) ,
8989 /// Write data from the provided buffer, discarding read data
90- Write ( & ' a [ W ] ) ,
90+ Write ( & ' a [ Word ] ) ,
9191 /// Write data out while reading data into the provided buffer
92- Transfer ( & ' a mut [ W ] , & ' a [ W ] ) ,
92+ Transfer ( & ' a mut [ Word ] , & ' a [ Word ] ) ,
9393 /// Write data out while reading data into the provided buffer
94- TransferInplace ( & ' a mut [ W ] ) ,
94+ TransferInplace ( & ' a mut [ Word ] ) ,
9595}
9696
9797/// Transactional trait allows multiple actions to be executed
9898/// as part of a single SPI transaction
99- pub trait Transactional < W : ' static + Copy = u8 > : ErrorType {
99+ pub trait Transactional < Word : ' static + Copy = u8 > : ErrorType {
100100 /// Execute the provided transactions
101- fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > ;
101+ fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , Word > ] ) -> Result < ( ) , Self :: Error > ;
102102}
103103
104- impl < T : Transactional < W > , W : ' static + Copy > Transactional < W > for & mut T {
105- fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > {
104+ impl < T : Transactional < Word > , Word : ' static + Copy > Transactional < Word > for & mut T {
105+ fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , Word > ] ) -> Result < ( ) , Self :: Error > {
106106 T :: exec ( self , operations)
107107 }
108108}
0 commit comments