File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ pub enum Error {
44
44
ZeroLengthTransfer ,
45
45
}
46
46
47
+ impl core:: fmt:: Display for Error {
48
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
49
+ let message = match self {
50
+ Self :: Bus => "Bus Error" ,
51
+ Self :: Arbitration => "Arbitration Lost" ,
52
+ Self :: Nack => "ACK Not Received" ,
53
+ Self :: Timeout => "Request Timed Out" ,
54
+ Self :: Crc => "CRC Mismatch" ,
55
+ Self :: Overrun => "Buffer Overrun" ,
56
+ Self :: ZeroLengthTransfer => "Zero-Length Transfers are not allowed" ,
57
+ } ;
58
+
59
+ write ! ( f, "{}" , message)
60
+ }
61
+ }
62
+
63
+ impl core:: error:: Error for Error { }
64
+
47
65
/// I2C config
48
66
#[ non_exhaustive]
49
67
#[ derive( Copy , Clone ) ]
Original file line number Diff line number Diff line change @@ -31,6 +31,21 @@ pub enum Error {
31
31
Overrun ,
32
32
}
33
33
34
+ impl core:: fmt:: Display for Error {
35
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
36
+ let message = match self {
37
+ Self :: Framing => "Invalid Framing" ,
38
+ Self :: Crc => "Hardware CRC Check Failed" ,
39
+ Self :: ModeFault => "Mode Fault" ,
40
+ Self :: Overrun => "Buffer Overrun" ,
41
+ } ;
42
+
43
+ write ! ( f, "{}" , message)
44
+ }
45
+ }
46
+
47
+ impl core:: error:: Error for Error { }
48
+
34
49
/// SPI bit order
35
50
#[ derive( Copy , Clone ) ]
36
51
pub enum BitOrder {
Original file line number Diff line number Diff line change @@ -293,6 +293,22 @@ pub enum Error {
293
293
BufferTooLong ,
294
294
}
295
295
296
+ impl core:: fmt:: Display for Error {
297
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
298
+ let message = match self {
299
+ Self :: Framing => "Framing Error" ,
300
+ Self :: Noise => "Noise Error" ,
301
+ Self :: Overrun => "RX Buffer Overrun" ,
302
+ Self :: Parity => "Parity Check Error" ,
303
+ Self :: BufferTooLong => "Buffer too large for DMA" ,
304
+ } ;
305
+
306
+ write ! ( f, "{}" , message)
307
+ }
308
+ }
309
+
310
+ impl core:: error:: Error for Error { }
311
+
296
312
enum ReadCompletionEvent {
297
313
// DMA Read transfer completed first
298
314
DmaCompleted ,
You can’t perform that action at this time.
0 commit comments