@@ -6,7 +6,10 @@ use embedded_hal::spi::{ErrorType, Operation, SpiBus, SpiDevice};
6
6
#[ cfg( feature = "async" ) ]
7
7
use embedded_hal_async:: {
8
8
delay:: DelayNs as AsyncDelayNs ,
9
- spi:: { SpiBus as AsyncSpiBus , SpiDevice as AsyncSpiDevice } ,
9
+ spi:: {
10
+ ErrorType as AsyncErrorType , Operation as AsyncOperation , SpiBus as AsyncSpiBus ,
11
+ SpiDevice as AsyncSpiDevice ,
12
+ } ,
10
13
} ;
11
14
12
15
use super :: shared:: transaction;
89
92
}
90
93
}
91
94
95
+ #[ cfg( feature = "async" ) ]
96
+ impl < BUS , CS , D > AsyncErrorType for ExclusiveDevice < BUS , CS , D >
97
+ where
98
+ BUS : AsyncErrorType ,
99
+ CS : OutputPin ,
100
+ {
101
+ type Error = DeviceError < BUS :: Error , CS :: Error > ;
102
+ }
103
+
92
104
#[ cfg( feature = "async" ) ]
93
105
#[ cfg_attr( docsrs, doc( cfg( feature = "async" ) ) ) ]
94
106
impl < Word : Copy + ' static , BUS , CS , D > AsyncSpiDevice < Word > for ExclusiveDevice < BUS , CS , D >
@@ -100,18 +112,18 @@ where
100
112
#[ inline]
101
113
async fn transaction (
102
114
& mut self ,
103
- operations : & mut [ Operation < ' _ , Word > ] ,
115
+ operations : & mut [ AsyncOperation < ' _ , Word > ] ,
104
116
) -> Result < ( ) , Self :: Error > {
105
117
self . cs . set_low ( ) . map_err ( DeviceError :: Cs ) ?;
106
118
107
119
let op_res = ' ops: {
108
120
for op in operations {
109
121
let res = match op {
110
- Operation :: Read ( buf) => self . bus . read ( buf) . await ,
111
- Operation :: Write ( buf) => self . bus . write ( buf) . await ,
112
- Operation :: Transfer ( read, write) => self . bus . transfer ( read, write) . await ,
113
- Operation :: TransferInPlace ( buf) => self . bus . transfer_in_place ( buf) . await ,
114
- Operation :: DelayNs ( ns) => match self . bus . flush ( ) . await {
122
+ AsyncOperation :: Read ( buf) => self . bus . read ( buf) . await ,
123
+ AsyncOperation :: Write ( buf) => self . bus . write ( buf) . await ,
124
+ AsyncOperation :: Transfer ( read, write) => self . bus . transfer ( read, write) . await ,
125
+ AsyncOperation :: TransferInPlace ( buf) => self . bus . transfer_in_place ( buf) . await ,
126
+ AsyncOperation :: DelayNs ( ns) => match self . bus . flush ( ) . await {
115
127
Err ( e) => Err ( e) ,
116
128
Ok ( ( ) ) => {
117
129
self . delay . delay_ns ( * ns) . await ;
0 commit comments