|
@@ -733,194 +733,176 @@ static bool PWM_status(uint8_t pin) {
|
733
|
733
|
SERIAL_PROTOCOLPGM(" ");
|
734
|
734
|
} //PWM_status
|
735
|
735
|
|
736
|
|
-static void PWM_details(uint8_t pin)
|
737
|
|
-{
|
|
736
|
+#define WGM_MAKE3(N) ((TEST(TCCR##N##B, WGM##N##2) >> 1) | (TCCR##N##A & (_BV(WGM##N##0) | _BV(WGM##N##1))))
|
|
737
|
+#define WGM_MAKE4(N) (WGM_MAKE3(N) | (TEST(TCCR##N##B, WGM##N##3) >> 1))
|
|
738
|
+#define TIMER_PREFIX(T,L,N) do{ \
|
|
739
|
+ WGM = WGM_MAKE##N(T); \
|
|
740
|
+ SERIAL_PROTOCOLPGM(" TIMER"); \
|
|
741
|
+ SERIAL_PROTOCOLPGM(STRINGIFY(T) STRINGIFY(L)); \
|
|
742
|
+ SERIAL_PROTOCOLPAIR(" WGM: ", WGM); \
|
|
743
|
+ SERIAL_PROTOCOLPAIR(" TIMSK" STRINGIFY(T) ": ", TIMSK##T); \
|
|
744
|
+ }while(0)
|
|
745
|
+
|
|
746
|
+#define WGM_TEST1 (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6)
|
|
747
|
+#define WGM_TEST2 (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13)
|
|
748
|
+
|
|
749
|
+static void err_is_counter() {
|
|
750
|
+ SERIAL_PROTOCOLPGM(" Can't ");
|
|
751
|
+ SERIAL_PROTOCOLPGM("be used as a PWM because ");
|
|
752
|
+ SERIAL_PROTOCOLPGM("of counter mode");
|
|
753
|
+}
|
|
754
|
+static void err_is_interrupt() {
|
|
755
|
+ SERIAL_PROTOCOLPGM(" Can't ");
|
|
756
|
+ SERIAL_PROTOCOLPGM("be used as a PWM because ");
|
|
757
|
+ SERIAL_PROTOCOLPGM("it's ");
|
|
758
|
+ SERIAL_PROTOCOLPGM("being used as an interrupt");
|
|
759
|
+}
|
|
760
|
+static void err_prob_interrupt() {
|
|
761
|
+ SERIAL_PROTOCOLPGM(" Probably can't ");
|
|
762
|
+ SERIAL_PROTOCOLPGM("be used as a PWM because ");
|
|
763
|
+ SERIAL_PROTOCOLPGM("counter/timer is ");
|
|
764
|
+ SERIAL_PROTOCOLPGM("being used as an interrupt");
|
|
765
|
+}
|
|
766
|
+static void can_be_used() { SERIAL_PROTOCOLPGM(" can be used as PWM "); }
|
738
|
767
|
|
739
|
|
- uint8_t WGM;
|
|
768
|
+static void PWM_details(uint8_t pin) {
|
|
769
|
+
|
|
770
|
+ uint8_t WGM;
|
740
|
771
|
|
741
|
772
|
switch(digitalPinToTimer(pin)) {
|
742
|
|
-
|
743
|
|
- #if defined(TCCR0A) && defined(COM0A1)
|
744
|
|
- case TIMER0A:
|
745
|
|
- SERIAL_PROTOCOLPGM(" TIMER0A");
|
746
|
|
- WGM = ((TCCR0B & _BV(WGM02)) >> 1 ) | (TCCR0A & (_BV(WGM00) | _BV(WGM01) ));
|
747
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
748
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK0: ", TIMSK0);
|
749
|
|
- if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
750
|
|
- else if (TIMSK0 & _BV(OCIE0A)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
751
|
|
- else if (TIMSK0 & _BV(TOIE0) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
752
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
753
|
|
- break;
|
754
|
|
- case TIMER0B:
|
755
|
|
- SERIAL_PROTOCOLPGM(" TIMER0B");
|
756
|
|
- WGM = ((TCCR0B & _BV(WGM02)) >> 1 ) | (TCCR0A & (_BV(WGM00) | _BV(WGM01) ));
|
757
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
758
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK0: ", TIMSK0);
|
759
|
|
- if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
760
|
|
- else if (TIMSK0 & _BV(OCIE0B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
761
|
|
- else if (TIMSK0 & _BV(TOIE0) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
762
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
763
|
|
- break;
|
764
|
|
- #endif
|
765
|
|
-
|
766
|
|
- #if defined(TCCR1A) && defined(COM1A1)
|
767
|
|
- case TIMER1A:
|
768
|
|
- SERIAL_PROTOCOLPGM(" TIMER1A");
|
769
|
|
- WGM = ((TCCR1B & (_BV(WGM12) | _BV(WGM13) )) >> 1 ) | (TCCR1A & (_BV(WGM10) | _BV(WGM11) ));
|
770
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
771
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK1: ", TIMSK1);
|
772
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
773
|
|
- else if (TIMSK1 & _BV(OCIE1A)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
774
|
|
- else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
775
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
776
|
|
- break;
|
777
|
|
- case TIMER1B:
|
778
|
|
- SERIAL_PROTOCOLPGM(" TIMER1B");
|
779
|
|
- WGM = ((TCCR1B & (_BV(WGM12) | _BV(WGM13) )) >> 1 ) | (TCCR1A & (_BV(WGM10) | _BV(WGM11) ));
|
780
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
781
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK1: ", TIMSK1);
|
782
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
783
|
|
- else if (TIMSK1 & _BV(OCIE1B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
784
|
|
- else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
785
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
786
|
|
- break;
|
787
|
|
- case TIMER1C:
|
788
|
|
- SERIAL_PROTOCOLPGM(" TIMER1C");
|
789
|
|
- WGM = ((TCCR1B & (_BV(WGM12) | _BV(WGM13) )) >> 1 ) | (TCCR1A & (_BV(WGM10) | _BV(WGM11) ));
|
790
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
791
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK1: ", TIMSK1);
|
792
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
793
|
|
- else if (TIMSK1 & _BV(OCIE1C)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
794
|
|
- else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
795
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
796
|
|
- break;
|
797
|
|
- #endif
|
798
|
|
-
|
799
|
|
- #if defined(TCCR2A) && defined(COM2A1)
|
800
|
|
- case TIMER2A:
|
801
|
|
- SERIAL_PROTOCOLPGM(" TIMER2A");
|
802
|
|
- WGM = ((TCCR2B & _BV(WGM22) ) >> 1 ) | (TCCR2A & (_BV(WGM20) | _BV(WGM21) ));
|
803
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
804
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK2: ", TIMSK2);
|
805
|
|
- if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
806
|
|
- else if (TIMSK2 & (_BV(TOIE2) | _BV(OCIE2A))) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
807
|
|
- else if (TIMSK2 & _BV(TOIE2) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
808
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
809
|
|
- break;
|
810
|
|
- case TIMER2B:
|
811
|
|
- SERIAL_PROTOCOLPGM(" TIMER2B");
|
812
|
|
- WGM = ((TCCR2B & _BV(WGM22) ) >> 1 ) | (TCCR2A & (_BV(WGM20) | _BV(WGM21) ));
|
813
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
814
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK2: ", TIMSK2);
|
815
|
|
- if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
816
|
|
- else if (TIMSK2 & _BV(OCIE2B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
817
|
|
- else if (TIMSK2 & _BV(TOIE2) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
818
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
819
|
|
- break;
|
820
|
|
- #endif
|
821
|
|
-
|
822
|
|
- #if defined(TCCR3A) && defined(COM3A1)
|
823
|
|
- case TIMER3A:
|
824
|
|
- SERIAL_PROTOCOLPGM(" TIMER3A");
|
825
|
|
- WGM = ((TCCR3B & _BV(WGM32) ) >> 1 ) | (TCCR3A & (_BV(WGM30) | _BV(WGM31) ));
|
826
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
827
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK3: ", TIMSK3);
|
828
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
829
|
|
- else if (TIMSK3 & _BV(OCIE3A)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
830
|
|
- else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
831
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
832
|
|
- break;
|
833
|
|
- case TIMER3B:
|
834
|
|
- SERIAL_PROTOCOLPGM(" TIMER3B");
|
835
|
|
- WGM = ((TCCR3B & _BV(WGM32) ) >> 1 ) | (TCCR3A & (_BV(WGM30) | _BV(WGM31) ));
|
836
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
837
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK3: ", TIMSK3);
|
838
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
839
|
|
- else if (TIMSK3 & _BV(OCIE3B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
840
|
|
- else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
841
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
842
|
|
- break;
|
843
|
|
- case TIMER3C:
|
844
|
|
- SERIAL_PROTOCOLPGM(" TIMER3C");
|
845
|
|
- WGM = ((TCCR3B & _BV(WGM32) ) >> 1 ) | (TCCR3A & (_BV(WGM30) | _BV(WGM31) ));
|
846
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
847
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK3: ", TIMSK3);
|
848
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
849
|
|
- else if (TIMSK3 & _BV(OCIE3C)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
850
|
|
- else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
851
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
852
|
|
- break;
|
853
|
|
- #endif
|
854
|
|
-
|
855
|
|
- #if defined(TCCR4A)
|
856
|
|
- case TIMER4A:
|
857
|
|
- SERIAL_PROTOCOLPGM(" TIMER4A");
|
858
|
|
- WGM = ((TCCR4B & (_BV(WGM42) | _BV(WGM43) )) >> 1 ) | (TCCR4A & (_BV(WGM40) | _BV(WGM41) ));
|
859
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
860
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK4: ", TIMSK4);
|
861
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
862
|
|
- else if (TIMSK4 & _BV(OCIE4A)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
863
|
|
- else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
864
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
865
|
|
- break;
|
866
|
|
- case TIMER4B:
|
867
|
|
- SERIAL_PROTOCOLPGM(" TIMER4B");
|
868
|
|
- WGM = ((TCCR4B & (_BV(WGM42) | _BV(WGM43) )) >> 1 ) | (TCCR4A & (_BV(WGM40) | _BV(WGM41) ));
|
869
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
870
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK4: ", TIMSK4);
|
871
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
872
|
|
- else if (TIMSK4 & _BV(OCIE4B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
873
|
|
- else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
874
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
875
|
|
- break;
|
876
|
|
- case TIMER4C:
|
877
|
|
- SERIAL_PROTOCOLPGM(" TIMER4C");
|
878
|
|
- WGM = ((TCCR4B & (_BV(WGM42) | _BV(WGM43) )) >> 1 ) | (TCCR4A & (_BV(WGM40) | _BV(WGM41) ));
|
879
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
880
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK4: ", TIMSK4);
|
881
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
882
|
|
- else if (TIMSK4 & _BV(OCIE4C)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
883
|
|
- else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
884
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
885
|
|
- break;
|
886
|
|
-
|
887
|
|
- #endif
|
888
|
|
-
|
889
|
|
- #if defined(TCCR5A) && defined(COM5A1)
|
890
|
|
- case TIMER5A:
|
891
|
|
- SERIAL_PROTOCOLPGM(" TIMER5A");
|
892
|
|
- WGM = ((TCCR5B & (_BV(WGM52) | _BV(WGM53) )) >> 1 ) | (TCCR5A & (_BV(WGM50) | _BV(WGM51) ));
|
893
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
894
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK5: ", TIMSK5);
|
895
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
896
|
|
- else if (TIMSK5 & _BV(OCIE5A)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
897
|
|
- else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
898
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
899
|
|
- break;
|
900
|
|
- case TIMER5B:
|
901
|
|
- SERIAL_PROTOCOLPGM(" TIMER5B");
|
902
|
|
- WGM = ((TCCR5B & (_BV(WGM52) | _BV(WGM53) )) >> 1 ) | (TCCR5A & (_BV(WGM50) | _BV(WGM51) ));
|
903
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
904
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK5: ", TIMSK5);
|
905
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
906
|
|
- else if (TIMSK5 & _BV(OCIE5B)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
907
|
|
- else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
908
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
909
|
|
- break;
|
910
|
|
- case TIMER5C:
|
911
|
|
- SERIAL_PROTOCOLPGM(" TIMER5C");
|
912
|
|
- WGM = ((TCCR5B & (_BV(WGM52) | _BV(WGM53) )) >> 1 ) | (TCCR5A & (_BV(WGM50) | _BV(WGM51) ));
|
913
|
|
- SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
914
|
|
- SERIAL_PROTOCOLPAIR(" TIMSK5: ", TIMSK5);
|
915
|
|
- if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode");
|
916
|
|
- else if (TIMSK5 & _BV(OCIE5C)) SERIAL_PROTOCOLPGM(" Can't be used as a PWM because being used to generate an interrupt");
|
917
|
|
- else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5)) ) SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer being used to generate an interrupt");
|
918
|
|
- else SERIAL_PROTOCOLPGM(" can be used as PWM ");
|
919
|
|
- break;
|
920
|
|
- #endif
|
921
|
|
-
|
922
|
|
- case NOT_ON_TIMER:
|
923
|
|
- break;
|
|
773
|
+
|
|
774
|
+ #if defined(TCCR0A) && defined(COM0A1)
|
|
775
|
+ case TIMER0A:
|
|
776
|
+ TIMER_PREFIX(0,A,3);
|
|
777
|
+ if (WGM_TEST1) err_is_counter();
|
|
778
|
+ else if (TEST(TIMSK0, OCIE0A)) err_is_interrupt();
|
|
779
|
+ else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt();
|
|
780
|
+ else can_be_used();
|
|
781
|
+ break;
|
|
782
|
+ case TIMER0B:
|
|
783
|
+ TIMER_PREFIX(0,B,3);
|
|
784
|
+ if (WGM_TEST1) err_is_counter();
|
|
785
|
+ else if (TEST(TIMSK0, OCIE0B)) err_is_interrupt();
|
|
786
|
+ else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt();
|
|
787
|
+ else can_be_used();
|
|
788
|
+ break;
|
|
789
|
+ #endif
|
|
790
|
+
|
|
791
|
+ #if defined(TCCR1A) && defined(COM1A1)
|
|
792
|
+ case TIMER1A:
|
|
793
|
+ TIMER_PREFIX(1,A,4);
|
|
794
|
+ if (WGM_TEST2) err_is_counter();
|
|
795
|
+ else if (TEST(TIMSK1, OCIE1A)) err_is_interrupt();
|
|
796
|
+ else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
|
|
797
|
+ else can_be_used();
|
|
798
|
+ break;
|
|
799
|
+ case TIMER1B:
|
|
800
|
+ TIMER_PREFIX(1,B,4);
|
|
801
|
+ if (WGM_TEST2) err_is_counter();
|
|
802
|
+ else if (TEST(TIMSK1, OCIE1B)) err_is_interrupt();
|
|
803
|
+ else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
|
|
804
|
+ else can_be_used();
|
|
805
|
+ break;
|
|
806
|
+ case TIMER1C:
|
|
807
|
+ TIMER_PREFIX(1,C,4);
|
|
808
|
+ if (WGM_TEST2) err_is_counter();
|
|
809
|
+ else if (TEST(TIMSK1, OCIE1C)) err_is_interrupt();
|
|
810
|
+ else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
|
|
811
|
+ else can_be_used();
|
|
812
|
+ break;
|
|
813
|
+ #endif
|
|
814
|
+
|
|
815
|
+ #if defined(TCCR2A) && defined(COM2A1)
|
|
816
|
+ case TIMER2A:
|
|
817
|
+ TIMER_PREFIX(2,A,3);
|
|
818
|
+ if (WGM_TEST1) err_is_counter();
|
|
819
|
+ else if (TIMSK2 & (_BV(TOIE2) | _BV(OCIE2A))) err_is_interrupt();
|
|
820
|
+ else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt();
|
|
821
|
+ else can_be_used();
|
|
822
|
+ break;
|
|
823
|
+ case TIMER2B:
|
|
824
|
+ TIMER_PREFIX(2,B,3);
|
|
825
|
+ if (WGM_TEST1) err_is_counter();
|
|
826
|
+ else if (TEST(TIMSK2, OCIE2B)) err_is_interrupt();
|
|
827
|
+ else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt();
|
|
828
|
+ else can_be_used();
|
|
829
|
+ break;
|
|
830
|
+ #endif
|
|
831
|
+
|
|
832
|
+ #if defined(TCCR3A) && defined(COM3A1)
|
|
833
|
+ case TIMER3A:
|
|
834
|
+ TIMER_PREFIX(3,A,3);
|
|
835
|
+ if (WGM_TEST2) err_is_counter();
|
|
836
|
+ else if (TEST(TIMSK3, OCIE3A)) err_is_interrupt();
|
|
837
|
+ else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
|
|
838
|
+ else can_be_used();
|
|
839
|
+ break;
|
|
840
|
+ case TIMER3B:
|
|
841
|
+ TIMER_PREFIX(3,B,3);
|
|
842
|
+ if (WGM_TEST2) err_is_counter();
|
|
843
|
+ else if (TEST(TIMSK3, OCIE3B)) err_is_interrupt();
|
|
844
|
+ else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
|
|
845
|
+ else can_be_used();
|
|
846
|
+ break;
|
|
847
|
+ case TIMER3C:
|
|
848
|
+ TIMER_PREFIX(3,C,3);
|
|
849
|
+ if (WGM_TEST2) err_is_counter();
|
|
850
|
+ else if (TEST(TIMSK3, OCIE3C)) err_is_interrupt();
|
|
851
|
+ else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
|
|
852
|
+ else can_be_used();
|
|
853
|
+ break;
|
|
854
|
+ #endif
|
|
855
|
+
|
|
856
|
+ #ifdef TCCR4A
|
|
857
|
+ case TIMER4A:
|
|
858
|
+ TIMER_PREFIX(4,A,4);
|
|
859
|
+ if (WGM_TEST2) err_is_counter();
|
|
860
|
+ else if (TEST(TIMSK4, OCIE4A)) err_is_interrupt();
|
|
861
|
+ else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
|
|
862
|
+ else can_be_used();
|
|
863
|
+ break;
|
|
864
|
+ case TIMER4B:
|
|
865
|
+ TIMER_PREFIX(4,B,4);
|
|
866
|
+ if (WGM_TEST2) err_is_counter();
|
|
867
|
+ else if (TEST(TIMSK4, OCIE4B)) err_is_interrupt();
|
|
868
|
+ else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
|
|
869
|
+ else can_be_used();
|
|
870
|
+ break;
|
|
871
|
+ case TIMER4C:
|
|
872
|
+ TIMER_PREFIX(4,C,4);
|
|
873
|
+ if (WGM_TEST2) err_is_counter();
|
|
874
|
+ else if (TEST(TIMSK4, OCIE4C)) err_is_interrupt();
|
|
875
|
+ else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt();
|
|
876
|
+ else can_be_used();
|
|
877
|
+ break;
|
|
878
|
+ #endif
|
|
879
|
+
|
|
880
|
+ #if defined(TCCR5A) && defined(COM5A1)
|
|
881
|
+ case TIMER5A:
|
|
882
|
+ TIMER_PREFIX(5,A,4);
|
|
883
|
+ if (WGM_TEST2) err_is_counter();
|
|
884
|
+ else if (TEST(TIMSK5, OCIE5A)) err_is_interrupt();
|
|
885
|
+ else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
|
|
886
|
+ else can_be_used();
|
|
887
|
+ break;
|
|
888
|
+ case TIMER5B:
|
|
889
|
+ TIMER_PREFIX(5,B,4);
|
|
890
|
+ if (WGM_TEST2) err_is_counter();
|
|
891
|
+ else if (TEST(TIMSK5, OCIE5B)) err_is_interrupt();
|
|
892
|
+ else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
|
|
893
|
+ else can_be_used();
|
|
894
|
+ break;
|
|
895
|
+ case TIMER5C:
|
|
896
|
+ TIMER_PREFIX(5,C,4);
|
|
897
|
+ if (WGM_TEST2) err_is_counter();
|
|
898
|
+ else if (TEST(TIMSK5, OCIE5C)) err_is_interrupt();
|
|
899
|
+ else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt();
|
|
900
|
+ else can_be_used();
|
|
901
|
+ break;
|
|
902
|
+ #endif
|
|
903
|
+
|
|
904
|
+ case NOT_ON_TIMER: break;
|
|
905
|
+
|
924
|
906
|
}
|
925
|
907
|
SERIAL_PROTOCOLPGM(" ");
|
926
|
908
|
} // PWM_details
|