22
33use display_interface:: { DisplayError , WriteOnlyDataCommand } ;
44use embedded_hal:: {
5- blocking:: {
6- i2c,
7- spi:: { self , Transfer } ,
8- } ,
9- digital:: v2:: OutputPin ,
5+ digital:: { ErrorType , OutputPin } ,
6+ i2c,
7+ spi:: { self , SpiBus } ,
108} ;
119
10+ #[ derive( PartialEq , Eq , Clone , Debug , Copy ) ]
11+ pub struct Error { }
12+
13+ impl embedded_hal:: digital:: Error for Error {
14+ fn kind ( & self ) -> embedded_hal:: digital:: ErrorKind {
15+ embedded_hal:: digital:: ErrorKind :: Other
16+ }
17+ }
18+
19+ impl i2c:: Error for Error {
20+ fn kind ( & self ) -> i2c:: ErrorKind {
21+ i2c:: ErrorKind :: Other
22+ }
23+ }
24+
25+ impl spi:: Error for Error {
26+ fn kind ( & self ) -> spi:: ErrorKind {
27+ spi:: ErrorKind :: Other
28+ }
29+ }
30+
1231#[ allow( dead_code) ]
1332#[ derive( Debug , Clone , Copy ) ]
1433pub struct SpiStub ;
1534
16- impl spi:: Write < u8 > for SpiStub {
17- type Error = ( ) ;
35+ impl spi:: ErrorType for SpiStub {
36+ type Error = Error ;
37+ }
1838
19- fn write ( & mut self , _buf : & [ u8 ] ) -> Result < ( ) , ( ) > {
39+ impl SpiBus < u8 > for SpiStub {
40+ fn read ( & mut self , _words : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
41+ todo ! ( )
42+ }
43+
44+ fn write ( & mut self , _words : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
45+ Ok ( ( ) )
46+ }
47+
48+ fn transfer ( & mut self , _read : & mut [ u8 ] , _write : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
2049 Ok ( ( ) )
2150 }
22- }
2351
24- impl Transfer < u8 > for SpiStub {
25- type Error = ( ) ;
52+ fn transfer_in_place ( & mut self , _words : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
53+ todo ! ( )
54+ }
2655
27- fn transfer < ' a > ( & mut self , buf : & ' a mut [ u8 ] ) -> Result < & ' a [ u8 ] , ( ) > {
28- Ok ( buf )
56+ fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
57+ todo ! ( )
2958 }
3059}
3160
3261#[ allow( dead_code) ]
3362#[ derive( Debug , Clone , Copy ) ]
3463pub struct I2cStub ;
3564
36- impl i2c:: Write for I2cStub {
37- type Error = ( ) ;
65+ impl i2c:: ErrorType for I2cStub {
66+ type Error = Error ;
67+ }
3868
39- fn write ( & mut self , _addr : u8 , _buf : & [ u8 ] ) -> Result < ( ) , ( ) > {
69+ impl i2c:: I2c for I2cStub {
70+ fn transaction (
71+ & mut self ,
72+ _address : u8 ,
73+ _operations : & mut [ i2c:: Operation < ' _ > ] ,
74+ ) -> Result < ( ) , Self :: Error > {
4075 Ok ( ( ) )
4176 }
4277}
@@ -45,14 +80,16 @@ impl i2c::Write for I2cStub {
4580#[ derive( Debug , Clone , Copy ) ]
4681pub struct PinStub ;
4782
48- impl OutputPin for PinStub {
49- type Error = ( ) ;
83+ impl ErrorType for PinStub {
84+ type Error = Error ;
85+ }
5086
51- fn set_high ( & mut self ) -> Result < ( ) , ( ) > {
87+ impl OutputPin for PinStub {
88+ fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
5289 Ok ( ( ) )
5390 }
5491
55- fn set_low ( & mut self ) -> Result < ( ) , ( ) > {
92+ fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
5693 Ok ( ( ) )
5794 }
5895}
0 commit comments