File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ macro_rules! hal {
232232
233233 impl Rx <$USARTX> {
234234 pub fn circ_read<B >(
235- self ,
235+ & self ,
236236 mut chan: $rx_chan,
237237 buffer: & ' static mut [ B ; 2 ] ,
238238 ) -> CircBuffer <B , $rx_chan>
@@ -289,6 +289,24 @@ macro_rules! hal {
289289
290290 CircBuffer :: new( buffer, chan)
291291 }
292+
293+ /// Checks to see if the usart peripheral has detected an idle line and clears the flag
294+ pub fn is_idle( & mut self , clear: bool ) -> bool {
295+ let isr = unsafe { & ( * $USARTX:: ptr( ) ) . isr. read( ) } ;
296+ let icr = unsafe { & ( * $USARTX:: ptr( ) ) . icr } ;
297+
298+ if isr. idle( ) . bit_is_set( ) {
299+ if clear {
300+ icr. write( |w| {
301+ w. idlecf( )
302+ . set_bit( )
303+ } ) ;
304+ }
305+ true
306+ } else {
307+ false
308+ }
309+ }
292310 }
293311 ) +
294312 }
You can’t perform that action at this time.
0 commit comments