@@ -17,7 +17,7 @@ impl<'a> Lpuart<'a, Blocking> {
1717 tx_pin : Peri < ' a , impl TxPin < T > > ,
1818 rx_pin : Peri < ' a , impl RxPin < T > > ,
1919 config : Config ,
20- ) -> Result < Self > {
20+ ) -> Result < Self , Error > {
2121 // Configure the pins for LPUART usage
2222 tx_pin. as_tx ( ) ;
2323 rx_pin. as_rx ( ) ;
@@ -39,7 +39,7 @@ impl<'a> Lpuart<'a, Blocking> {
3939 cts_pin : Peri < ' a , impl CtsPin < T > > ,
4040 rts_pin : Peri < ' a , impl RtsPin < T > > ,
4141 config : Config ,
42- ) -> Result < Self > {
42+ ) -> Result < Self , Error > {
4343 // Configure the pins for LPUART usage
4444 rx_pin. as_rx ( ) ;
4545 tx_pin. as_tx ( ) ;
@@ -54,21 +54,21 @@ impl<'a> Lpuart<'a, Blocking> {
5454 }
5555
5656 /// Read data from LPUART RX blocking execution until the buffer is filled
57- pub fn blocking_read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) > {
57+ pub fn blocking_read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) , Error > {
5858 self . rx . blocking_read ( buf)
5959 }
6060
6161 /// Read data from LPUART RX without blocking
62- pub fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) > {
62+ pub fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) , Error > {
6363 self . rx . read ( buf)
6464 }
6565
6666 /// Write data to LPUART TX blocking execution until all data is sent
67- pub fn blocking_write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) > {
67+ pub fn blocking_write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Error > {
6868 self . tx . blocking_write ( buf)
6969 }
7070
71- pub fn write_byte ( & mut self , byte : u8 ) -> Result < ( ) > {
71+ pub fn write_byte ( & mut self , byte : u8 ) -> Result < ( ) , Error > {
7272 self . tx . write_byte ( byte)
7373 }
7474
@@ -85,17 +85,17 @@ impl<'a> Lpuart<'a, Blocking> {
8585 }
8686
8787 /// Write data to LPUART TX without blocking
88- pub fn write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) > {
88+ pub fn write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Error > {
8989 self . tx . write ( buf)
9090 }
9191
9292 /// Flush LPUART TX blocking execution until all data has been transmitted
93- pub fn blocking_flush ( & mut self ) -> Result < ( ) > {
93+ pub fn blocking_flush ( & mut self ) -> Result < ( ) , Error > {
9494 self . tx . blocking_flush ( )
9595 }
9696
9797 /// Flush LPUART TX without blocking
98- pub fn flush ( & mut self ) -> Result < ( ) > {
98+ pub fn flush ( & mut self ) -> Result < ( ) , Error > {
9999 self . tx . flush ( )
100100 }
101101}
@@ -108,7 +108,7 @@ impl<'a> LpuartTx<'a, Blocking> {
108108 _inner : Peri < ' a , T > ,
109109 tx_pin : Peri < ' a , impl TxPin < T > > ,
110110 config : Config ,
111- ) -> Result < Self > {
111+ ) -> Result < Self , Error > {
112112 // Configure the pins for LPUART usage
113113 tx_pin. as_tx ( ) ;
114114
@@ -124,26 +124,26 @@ impl<'a> LpuartTx<'a, Blocking> {
124124 tx_pin : Peri < ' a , impl TxPin < T > > ,
125125 cts_pin : Peri < ' a , impl CtsPin < T > > ,
126126 config : Config ,
127- ) -> Result < Self > {
127+ ) -> Result < Self , Error > {
128128 tx_pin. as_tx ( ) ;
129129 cts_pin. as_cts ( ) ;
130130
131131 let wg = Lpuart :: < Blocking > :: init :: < T > ( true , false , true , false , config) ?;
132132 Ok ( Self :: new_inner :: < T > ( tx_pin. into ( ) , Some ( cts_pin. into ( ) ) , Blocking , wg) )
133133 }
134134
135- fn write_byte_internal ( & mut self , byte : u8 ) -> Result < ( ) > {
135+ fn write_byte_internal ( & mut self , byte : u8 ) -> Result < ( ) , Error > {
136136 self . info . regs ( ) . data ( ) . modify ( |w| w. 0 = u32:: from ( byte) ) ;
137137
138138 Ok ( ( ) )
139139 }
140140
141- fn blocking_write_byte ( & mut self , byte : u8 ) -> Result < ( ) > {
141+ fn blocking_write_byte ( & mut self , byte : u8 ) -> Result < ( ) , Error > {
142142 while self . info . regs ( ) . stat ( ) . read ( ) . tdre ( ) == Tdre :: TXDATA { }
143143 self . write_byte_internal ( byte)
144144 }
145145
146- fn write_byte ( & mut self , byte : u8 ) -> Result < ( ) > {
146+ fn write_byte ( & mut self , byte : u8 ) -> Result < ( ) , Error > {
147147 if self . info . regs ( ) . stat ( ) . read ( ) . tdre ( ) == Tdre :: TXDATA {
148148 Err ( Error :: TxFifoFull )
149149 } else {
@@ -152,7 +152,7 @@ impl<'a> LpuartTx<'a, Blocking> {
152152 }
153153
154154 /// Write data to LPUART TX blocking execution until all data is sent.
155- pub fn blocking_write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) > {
155+ pub fn blocking_write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Error > {
156156 for x in buf {
157157 self . blocking_write_byte ( * x) ?;
158158 }
@@ -165,7 +165,7 @@ impl<'a> LpuartTx<'a, Blocking> {
165165 }
166166
167167 /// Write data to LPUART TX without blocking.
168- pub fn write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) > {
168+ pub fn write ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Error > {
169169 for x in buf {
170170 self . write_byte ( * x) ?;
171171 }
@@ -174,7 +174,7 @@ impl<'a> LpuartTx<'a, Blocking> {
174174 }
175175
176176 /// Flush LPUART TX blocking execution until all data has been transmitted.
177- pub fn blocking_flush ( & mut self ) -> Result < ( ) > {
177+ pub fn blocking_flush ( & mut self ) -> Result < ( ) , Error > {
178178 while self . info . regs ( ) . water ( ) . read ( ) . txcount ( ) != 0 {
179179 // Wait for TX FIFO to drain
180180 }
@@ -188,7 +188,7 @@ impl<'a> LpuartTx<'a, Blocking> {
188188 }
189189
190190 /// Flush LPUART TX.
191- pub fn flush ( & mut self ) -> Result < ( ) > {
191+ pub fn flush ( & mut self ) -> Result < ( ) , Error > {
192192 // Check if TX FIFO is empty
193193 if self . info . regs ( ) . water ( ) . read ( ) . txcount ( ) != 0 {
194194 return Err ( Error :: TxBusy ) ;
@@ -211,7 +211,7 @@ impl<'a> LpuartRx<'a, Blocking> {
211211 _inner : Peri < ' a , T > ,
212212 rx_pin : Peri < ' a , impl RxPin < T > > ,
213213 config : Config ,
214- ) -> Result < Self > {
214+ ) -> Result < Self , Error > {
215215 rx_pin. as_rx ( ) ;
216216
217217 let wg = Lpuart :: < Blocking > :: init :: < T > ( false , true , false , false , config) ?;
@@ -226,19 +226,19 @@ impl<'a> LpuartRx<'a, Blocking> {
226226 rx_pin : Peri < ' a , impl RxPin < T > > ,
227227 rts_pin : Peri < ' a , impl RtsPin < T > > ,
228228 config : Config ,
229- ) -> Result < Self > {
229+ ) -> Result < Self , Error > {
230230 rx_pin. as_rx ( ) ;
231231 rts_pin. as_rts ( ) ;
232232
233233 let wg = Lpuart :: < Blocking > :: init :: < T > ( false , true , false , true , config) ?;
234234 Ok ( Self :: new_inner :: < T > ( rx_pin. into ( ) , Some ( rts_pin. into ( ) ) , Blocking , wg) )
235235 }
236236
237- fn read_byte_internal ( & mut self ) -> Result < u8 > {
237+ fn read_byte_internal ( & mut self ) -> Result < u8 , Error > {
238238 Ok ( ( self . info . regs ( ) . data ( ) . read ( ) . 0 & 0xFF ) as u8 )
239239 }
240240
241- fn read_byte ( & mut self ) -> Result < u8 > {
241+ fn read_byte ( & mut self ) -> Result < u8 , Error > {
242242 check_and_clear_rx_errors ( self . info ) ?;
243243
244244 if !has_rx_data_pending ( self . info ) {
@@ -248,7 +248,7 @@ impl<'a> LpuartRx<'a, Blocking> {
248248 self . read_byte_internal ( )
249249 }
250250
251- fn blocking_read_byte ( & mut self ) -> Result < u8 > {
251+ fn blocking_read_byte ( & mut self ) -> Result < u8 , Error > {
252252 loop {
253253 if has_rx_data_pending ( self . info ) {
254254 return self . read_byte_internal ( ) ;
@@ -259,15 +259,15 @@ impl<'a> LpuartRx<'a, Blocking> {
259259 }
260260
261261 /// Read data from LPUART RX without blocking.
262- pub fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) > {
262+ pub fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) , Error > {
263263 for byte in buf. iter_mut ( ) {
264264 * byte = self . read_byte ( ) ?;
265265 }
266266 Ok ( ( ) )
267267 }
268268
269269 /// Read data from LPUART RX blocking execution until the buffer is filled.
270- pub fn blocking_read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) > {
270+ pub fn blocking_read ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) , Error > {
271271 for byte in buf. iter_mut ( ) {
272272 * byte = self . blocking_read_byte ( ) ?;
273273 }
0 commit comments