|
@@ -675,168 +675,62 @@ static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
|
675
|
675
|
return false;
|
676
|
676
|
} // report_pin_name
|
677
|
677
|
|
678
|
|
-// True - currently a PWM pin
|
|
678
|
+#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
|
|
679
|
+#define PWM_CASE(N) \
|
|
680
|
+ case TIMER##N: \
|
|
681
|
+ if (TCCR##N & (_BV(COM## N ##1) | _BV(COM## N ##0))) { \
|
|
682
|
+ PWM_PRINT(OCR##N); \
|
|
683
|
+ return true; \
|
|
684
|
+ } else return false
|
|
685
|
+
|
|
686
|
+/**
|
|
687
|
+ * Print a pin's PWM status.
|
|
688
|
+ * Return true if it's currently a PWM pin.
|
|
689
|
+ */
|
679
|
690
|
static bool PWM_status(uint8_t pin) {
|
680
|
691
|
char buffer[20]; // for the sprintf statements
|
681
|
692
|
|
682
|
693
|
switch(digitalPinToTimer(pin)) {
|
683
|
694
|
|
684
|
695
|
#if defined(TCCR0A) && defined(COM0A1)
|
685
|
|
- case TIMER0A:
|
686
|
|
- if (TCCR0A & (_BV(COM0A1) | _BV(COM0A0))){
|
687
|
|
- sprintf(buffer, "PWM: %4d", OCR0A);
|
688
|
|
- SERIAL_ECHO(buffer);
|
689
|
|
- return true;
|
690
|
|
- }
|
691
|
|
- else return false;
|
692
|
|
- break;
|
693
|
|
- case TIMER0B:
|
694
|
|
- if (TCCR0A & (_BV(COM0B1) | _BV(COM0B0))){
|
695
|
|
- sprintf(buffer, "PWM: %4d",OCR0B);
|
696
|
|
- SERIAL_ECHO(buffer);
|
697
|
|
- return true;
|
698
|
|
- }
|
699
|
|
- else return false;
|
700
|
|
- break;
|
|
696
|
+ PWM_CASE(0A);
|
|
697
|
+ PWM_CASE(0B);
|
701
|
698
|
#endif
|
702
|
699
|
|
703
|
700
|
#if defined(TCCR1A) && defined(COM1A1)
|
704
|
|
- case TIMER1A:
|
705
|
|
- if (TCCR1A & (_BV(COM1A1) | _BV(COM1A0))){
|
706
|
|
- sprintf(buffer, "PWM: %4d",OCR1A);
|
707
|
|
- SERIAL_ECHO(buffer);
|
708
|
|
- return true;
|
709
|
|
- }
|
710
|
|
- else return false;
|
711
|
|
- break;
|
712
|
|
- case TIMER1B:
|
713
|
|
- if (TCCR1A & (_BV(COM1B1) | _BV(COM1B0))){
|
714
|
|
- sprintf(buffer, "PWM: %4d",OCR1B);
|
715
|
|
- SERIAL_ECHO(buffer);
|
716
|
|
- return true;
|
717
|
|
- }
|
718
|
|
- else return false;
|
719
|
|
- break;
|
720
|
|
- case TIMER1C:
|
721
|
|
- if (TCCR1A & (_BV(COM1C1) | _BV(COM1C0))){
|
722
|
|
- sprintf(buffer, "PWM: %4d",OCR1C);
|
723
|
|
- SERIAL_ECHO(buffer);
|
724
|
|
- return true;
|
725
|
|
- }
|
726
|
|
- else return false;
|
727
|
|
- break;
|
|
701
|
+ PWM_CASE(1A);
|
|
702
|
+ PWM_CASE(1B);
|
|
703
|
+ PWM_CASE(1C);
|
728
|
704
|
#endif
|
729
|
705
|
|
730
|
706
|
#if defined(TCCR2A) && defined(COM2A1)
|
731
|
|
- case TIMER2A:
|
732
|
|
- if (TCCR2A & (_BV(COM2A1) | _BV(COM2A0))){
|
733
|
|
- sprintf(buffer, "PWM: %4d",OCR2A);
|
734
|
|
- SERIAL_ECHO(buffer);
|
735
|
|
- return true;
|
736
|
|
- }
|
737
|
|
- else return false;
|
738
|
|
- break;
|
739
|
|
- case TIMER2B:
|
740
|
|
- if (TCCR2A & (_BV(COM2B1) | _BV(COM2B0))){
|
741
|
|
- sprintf(buffer, "PWM: %4d",OCR2B);
|
742
|
|
- SERIAL_ECHO(buffer);
|
743
|
|
- return true;
|
744
|
|
- }
|
745
|
|
- else return false;
|
746
|
|
- break;
|
|
707
|
+ PWM_CASE(2A);
|
|
708
|
+ PWM_CASE(2B);
|
747
|
709
|
#endif
|
748
|
710
|
|
749
|
711
|
#if defined(TCCR3A) && defined(COM3A1)
|
750
|
|
- case TIMER3A:
|
751
|
|
- if (TCCR3A & (_BV(COM3A1) | _BV(COM3A0))){
|
752
|
|
- sprintf(buffer, "PWM: %4d",OCR3A);
|
753
|
|
- SERIAL_ECHO(buffer);
|
754
|
|
- return true;
|
755
|
|
- }
|
756
|
|
- else return false;
|
757
|
|
- break;
|
758
|
|
- case TIMER3B:
|
759
|
|
- if (TCCR3A & (_BV(COM3B1) | _BV(COM3B0))){
|
760
|
|
- sprintf(buffer, "PWM: %4d",OCR3B);
|
761
|
|
- SERIAL_ECHO(buffer);
|
762
|
|
- return true;
|
763
|
|
- }
|
764
|
|
- else return false;
|
765
|
|
- break;
|
766
|
|
- case TIMER3C:
|
767
|
|
- if (TCCR3A & (_BV(COM3C1) | _BV(COM3C0))){
|
768
|
|
- sprintf(buffer, "PWM: %4d",OCR3C);
|
769
|
|
- SERIAL_ECHO(buffer);
|
770
|
|
- return true;
|
771
|
|
- }
|
772
|
|
- else return false;
|
773
|
|
- break;
|
|
712
|
+ PWM_CASE(3A);
|
|
713
|
+ PWM_CASE(3B);
|
|
714
|
+ PWM_CASE(3C);
|
774
|
715
|
#endif
|
775
|
716
|
|
776
|
717
|
#ifdef TCCR4A
|
777
|
|
- case TIMER4A:
|
778
|
|
- if (TCCR4A & (_BV(COM4A1) | _BV(COM4A0))){
|
779
|
|
- sprintf(buffer, "PWM: %4d",OCR4A);
|
780
|
|
- SERIAL_ECHO(buffer);
|
781
|
|
- return true;
|
782
|
|
- }
|
783
|
|
- else return false;
|
784
|
|
- break;
|
785
|
|
- case TIMER4B:
|
786
|
|
- if (TCCR4A & (_BV(COM4B1) | _BV(COM4B0))){
|
787
|
|
- sprintf(buffer, "PWM: %4d",OCR4B);
|
788
|
|
- SERIAL_ECHO(buffer);
|
789
|
|
- return true;
|
790
|
|
- }
|
791
|
|
- else return false;
|
792
|
|
- break;
|
793
|
|
- case TIMER4C:
|
794
|
|
- if (TCCR4A & (_BV(COM4C1) | _BV(COM4C0))){
|
795
|
|
- sprintf(buffer, "PWM: %4d",OCR4C);
|
796
|
|
- SERIAL_ECHO(buffer);
|
797
|
|
- return true;
|
798
|
|
- }
|
799
|
|
- else return false;
|
800
|
|
- break;
|
|
718
|
+ PWM_CASE(4A);
|
|
719
|
+ PWM_CASE(4B);
|
|
720
|
+ PWM_CASE(4C);
|
801
|
721
|
#endif
|
802
|
722
|
|
803
|
723
|
#if defined(TCCR5A) && defined(COM5A1)
|
804
|
|
- case TIMER5A:
|
805
|
|
- if (TCCR5A & (_BV(COM5A1) | _BV(COM5A0))){
|
806
|
|
- sprintf(buffer, "PWM: %4d",OCR5A);
|
807
|
|
- SERIAL_ECHO(buffer);
|
808
|
|
- return true;
|
809
|
|
- }
|
810
|
|
- else return false;
|
811
|
|
- break;
|
812
|
|
- case TIMER5B:
|
813
|
|
- if (TCCR5A & (_BV(COM5B1) | _BV(COM5B0))){
|
814
|
|
- sprintf(buffer, "PWM: %4d",OCR5B);
|
815
|
|
- SERIAL_ECHO(buffer);
|
816
|
|
- return true;
|
817
|
|
- }
|
818
|
|
- else return false;
|
819
|
|
- break;
|
820
|
|
- case TIMER5C:
|
821
|
|
- if (TCCR5A & (_BV(COM5C1) | _BV(COM5C0))){
|
822
|
|
- sprintf(buffer, "PWM: %4d",OCR5C);
|
823
|
|
- SERIAL_ECHO(buffer);
|
824
|
|
- return true;
|
825
|
|
- }
|
826
|
|
- else return false;
|
827
|
|
- break;
|
|
724
|
+ PWM_CASE(5A);
|
|
725
|
+ PWM_CASE(5B);
|
|
726
|
+ PWM_CASE(5C);
|
828
|
727
|
#endif
|
829
|
728
|
|
830
|
729
|
case NOT_ON_TIMER:
|
831
|
|
- return false;
|
832
|
|
- break;
|
833
|
|
-
|
834
|
730
|
default:
|
835
|
731
|
return false;
|
836
|
|
-
|
837
|
732
|
}
|
838
|
|
-
|
839
|
|
- SERIAL_PROTOCOLPGM(" ");
|
|
733
|
+ SERIAL_PROTOCOLPGM(" ");
|
840
|
734
|
} //PWM_status
|
841
|
735
|
|
842
|
736
|
static void PWM_details(uint8_t pin)
|