@@ -4,7 +4,7 @@ pub use embedded_hal::spi::{
44 Error , ErrorKind , ErrorType , Mode , Operation , Phase , Polarity , MODE_0 , MODE_1 , MODE_2 , MODE_3 ,
55} ;
66
7- /// SPI device trait
7+ /// SPI device trait.
88///
99/// `SpiDevice` represents ownership over a single SPI device on a (possibly shared) bus, selected
1010/// with a CS (Chip Select) pin.
@@ -36,6 +36,7 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
3636 /// This is a convenience method equivalent to `device.read_transaction(&mut [buf])`.
3737 ///
3838 /// See also: [`SpiDevice::transaction`], [`SpiDevice::read`]
39+ #[ inline]
3940 async fn read ( & mut self , buf : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
4041 self . transaction ( & mut [ Operation :: Read ( buf) ] ) . await
4142 }
@@ -45,6 +46,7 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
4546 /// This is a convenience method equivalent to `device.write_transaction(&mut [buf])`.
4647 ///
4748 /// See also: [`SpiDevice::transaction`], [`SpiDevice::write`]
49+ #[ inline]
4850 async fn write ( & mut self , buf : & [ Word ] ) -> Result < ( ) , Self :: Error > {
4951 self . transaction ( & mut [ Operation :: Write ( buf) ] ) . await
5052 }
@@ -54,6 +56,7 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
5456 /// This is a convenience method equivalent to `device.transaction(|bus| bus.transfer(read, write))`.
5557 ///
5658 /// See also: [`SpiDevice::transaction`], [`SpiBus::transfer`]
59+ #[ inline]
5760 async fn transfer ( & mut self , read : & mut [ Word ] , write : & [ Word ] ) -> Result < ( ) , Self :: Error > {
5861 self . transaction ( & mut [ Operation :: Transfer ( read, write) ] )
5962 . await
@@ -64,38 +67,44 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
6467 /// This is a convenience method equivalent to `device.transaction(|bus| bus.transfer_in_place(buf))`.
6568 ///
6669 /// See also: [`SpiDevice::transaction`], [`SpiBus::transfer_in_place`]
70+ #[ inline]
6771 async fn transfer_in_place ( & mut self , buf : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
6872 self . transaction ( & mut [ Operation :: TransferInPlace ( buf) ] )
6973 . await
7074 }
7175}
7276
7377impl < Word : Copy + ' static , T : SpiDevice < Word > + ?Sized > SpiDevice < Word > for & mut T {
78+ #[ inline]
7479 async fn transaction (
7580 & mut self ,
7681 operations : & mut [ Operation < ' _ , Word > ] ,
7782 ) -> Result < ( ) , Self :: Error > {
7883 T :: transaction ( self , operations) . await
7984 }
8085
86+ #[ inline]
8187 async fn read ( & mut self , buf : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
8288 T :: read ( self , buf) . await
8389 }
8490
91+ #[ inline]
8592 async fn write ( & mut self , buf : & [ Word ] ) -> Result < ( ) , Self :: Error > {
8693 T :: write ( self , buf) . await
8794 }
8895
96+ #[ inline]
8997 async fn transfer ( & mut self , read : & mut [ Word ] , write : & [ Word ] ) -> Result < ( ) , Self :: Error > {
9098 T :: transfer ( self , read, write) . await
9199 }
92100
101+ #[ inline]
93102 async fn transfer_in_place ( & mut self , buf : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
94103 T :: transfer_in_place ( self , buf) . await
95104 }
96105}
97106
98- /// SPI bus
107+ /// SPI bus.
99108///
100109/// `SpiBus` represents **exclusive ownership** over the whole SPI bus, with SCK, MOSI and MISO pins.
101110///
@@ -110,7 +119,7 @@ pub trait SpiBus<Word: 'static + Copy = u8>: ErrorType {
110119 /// complete. See (the docs on embedded-hal)[embedded_hal::spi] for details on flushing.
111120 async fn read ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > ;
112121
113- /// Write `words` to the slave, ignoring all the incoming words
122+ /// Write `words` to the slave, ignoring all the incoming words.
114123 ///
115124 /// Implementations are allowed to return before the operation is
116125 /// complete. See (the docs on embedded-hal)[embedded_hal::spi] for details on flushing.
@@ -144,22 +153,27 @@ pub trait SpiBus<Word: 'static + Copy = u8>: ErrorType {
144153}
145154
146155impl < T : SpiBus < Word > + ?Sized , Word : ' static + Copy > SpiBus < Word > for & mut T {
156+ #[ inline]
147157 async fn read ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
148158 T :: read ( self , words) . await
149159 }
150160
161+ #[ inline]
151162 async fn write ( & mut self , words : & [ Word ] ) -> Result < ( ) , Self :: Error > {
152163 T :: write ( self , words) . await
153164 }
154165
166+ #[ inline]
155167 async fn transfer ( & mut self , read : & mut [ Word ] , write : & [ Word ] ) -> Result < ( ) , Self :: Error > {
156168 T :: transfer ( self , read, write) . await
157169 }
158170
171+ #[ inline]
159172 async fn transfer_in_place ( & mut self , words : & mut [ Word ] ) -> Result < ( ) , Self :: Error > {
160173 T :: transfer_in_place ( self , words) . await
161174 }
162175
176+ #[ inline]
163177 async fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
164178 T :: flush ( self ) . await
165179 }
0 commit comments