@@ -575,6 +575,63 @@ macro_rules! hal {
575
575
576
576
Ok ( ( ) )
577
577
}
578
+
579
+ /// Checks to see if the USART peripheral has detected an idle line and clears
580
+ /// the flag
581
+ pub fn is_idle( & mut self , clear: bool ) -> bool {
582
+ let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
583
+ let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
584
+
585
+ if isr. idle( ) . bit_is_set( ) {
586
+ if clear {
587
+ icr. write( |w| w. idlecf( ) . set_bit( ) ) ;
588
+ }
589
+ true
590
+ } else {
591
+ false
592
+ }
593
+ }
594
+
595
+
596
+ /// Checks to see if the USART peripheral has detected an receiver timeout and
597
+ /// clears the flag
598
+ pub fn is_receiver_timeout( & mut self , clear: bool ) -> bool {
599
+ let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
600
+ let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
601
+
602
+ if isr. rtof( ) . bit_is_set( ) {
603
+ if clear {
604
+ icr. write( |w| w. rtocf( ) . set_bit( ) ) ;
605
+ }
606
+ true
607
+ } else {
608
+ false
609
+ }
610
+ }
611
+
612
+ /// Checks to see if the USART peripheral has detected an character match and
613
+ /// clears the flag
614
+ pub fn check_character_match( & mut self , clear: bool ) -> bool {
615
+ let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
616
+ let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
617
+
618
+ if isr. cmf( ) . bit_is_set( ) {
619
+ if clear {
620
+ icr. write( |w| w. cmcf( ) . set_bit( ) ) ;
621
+ }
622
+ true
623
+ } else {
624
+ false
625
+ }
626
+ }
627
+ }
628
+
629
+ impl crate :: dma:: CharacterMatch for Rx <pac:: $USARTX> {
630
+ /// Checks to see if the USART peripheral has detected an character match and
631
+ /// clears the flag
632
+ fn check_character_match( & mut self , clear: bool ) -> bool {
633
+ self . check_character_match( clear)
634
+ }
578
635
}
579
636
580
637
impl Tx <pac:: $USARTX> {
@@ -665,7 +722,7 @@ macro_rules! hal {
665
722
impl $rxdma {
666
723
/// Create a frame reader that can either react on the Character match interrupt or
667
724
/// Transfer Complete from the DMA.
668
- pub fn frame_read <BUFFER , const N : usize >(
725
+ pub fn frame_reader <BUFFER , const N : usize >(
669
726
mut self ,
670
727
buffer: BUFFER ,
671
728
) -> FrameReader <BUFFER , Self , N >
@@ -712,54 +769,6 @@ macro_rules! hal {
712
769
713
770
FrameReader :: new( buffer, self , usart. cr2. read( ) . add( ) . bits( ) )
714
771
}
715
-
716
- /// Checks to see if the USART peripheral has detected an idle line and clears
717
- /// the flag
718
- pub fn is_idle( & mut self , clear: bool ) -> bool {
719
- let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
720
- let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
721
-
722
- if isr. idle( ) . bit_is_set( ) {
723
- if clear {
724
- icr. write( |w| w. idlecf( ) . set_bit( ) ) ;
725
- }
726
- true
727
- } else {
728
- false
729
- }
730
- }
731
-
732
- /// Checks to see if the USART peripheral has detected an character match and
733
- /// clears the flag
734
- pub fn is_character_match( & mut self , clear: bool ) -> bool {
735
- let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
736
- let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
737
-
738
- if isr. cmf( ) . bit_is_set( ) {
739
- if clear {
740
- icr. write( |w| w. cmcf( ) . set_bit( ) ) ;
741
- }
742
- true
743
- } else {
744
- false
745
- }
746
- }
747
-
748
- /// Checks to see if the USART peripheral has detected an receiver timeout and
749
- /// clears the flag
750
- pub fn is_receiver_timeout( & mut self , clear: bool ) -> bool {
751
- let isr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . isr. read( ) } ;
752
- let icr = unsafe { & ( * pac:: $USARTX:: ptr( ) ) . icr } ;
753
-
754
- if isr. rtof( ) . bit_is_set( ) {
755
- if clear {
756
- icr. write( |w| w. rtocf( ) . set_bit( ) ) ;
757
- }
758
- true
759
- } else {
760
- false
761
- }
762
- }
763
772
}
764
773
765
774
impl $txdma {
0 commit comments