@@ -39,6 +39,25 @@ pub mod i2c {
3939 * self
4040 }
4141 }
42+
43+ impl core:: fmt:: Display for ErrorKind {
44+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
45+ match self {
46+ Self :: Bus => write ! ( f, "An unspecific bus error occurred" ) ,
47+ Self :: ArbitrationLoss => write ! (
48+ f,
49+ "The arbitration was lost, e.g. electrical problems with the clock signal"
50+ ) ,
51+ Self :: NoAcknowledge => write ! ( f, "A bus operation was not acknowledged" ) ,
52+ Self :: Overrun => write ! ( f, "The peripheral receive buffer was overrun" ) ,
53+ Self :: Underrun => write ! ( f, "The peripheral send buffer ran out of data" ) ,
54+ Self :: Other => write ! (
55+ f,
56+ "A different error occurred. The original error may contain more information"
57+ ) ,
58+ }
59+ }
60+ }
4261}
4362
4463pub mod spi {
@@ -79,6 +98,28 @@ pub mod spi {
7998 * self
8099 }
81100 }
101+
102+ impl core:: fmt:: Display for ErrorKind {
103+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
104+ match self {
105+ Self :: Bus => write ! ( f, "An unspecific bus error occurred" ) ,
106+ Self :: Overrun => write ! ( f, "The peripheral receive buffer was overrun" ) ,
107+ Self :: ModeFault => write ! (
108+ f,
109+ "Multiple devices on the SPI bus are trying across each other"
110+ ) ,
111+ Self :: Crc => write ! ( f, "CRC does not match the received data" ) ,
112+ Self :: FrameFormat => write ! (
113+ f,
114+ "Received data does not conform to the peripheral configuration"
115+ ) ,
116+ Self :: Other => write ! (
117+ f,
118+ "A different error occurred. The original error may contain more information"
119+ ) ,
120+ }
121+ }
122+ }
82123}
83124
84125pub mod serial {
@@ -118,4 +159,22 @@ pub mod serial {
118159 * self
119160 }
120161 }
162+
163+ impl core:: fmt:: Display for ErrorKind {
164+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
165+ match self {
166+ Self :: Overrun => write ! ( f, "The peripheral receive buffer was overrun" ) ,
167+ Self :: Parity => write ! ( f, "Parity check failed" ) ,
168+ Self :: Noise => write ! ( f, "Serial line is too noisy to read valid data" ) ,
169+ Self :: FrameFormat => write ! (
170+ f,
171+ "Received data does not conform to the peripheral configuration"
172+ ) ,
173+ Self :: Other => write ! (
174+ f,
175+ "A different error occurred. The original error may contain more information"
176+ ) ,
177+ }
178+ }
179+ }
121180}
0 commit comments