@@ -102,7 +102,7 @@ void PRINT_ARRAY_NAME(uint8_t x) {
102102 return true; \
103103 } else return false
104104
105-
105+ #define ABTEST ( N ) defined(TCCR##N##A) && defined(COM##N##A1)
106106
107107/**
108108 * Print a pin's PWM status.
@@ -113,7 +113,7 @@ static bool pwm_status(uint8_t pin) {
113113
114114 switch (digitalPinToTimer_DEBUG (pin )) {
115115
116- #if defined( TCCR0A ) && defined( COM0A1 )
116+ #if ABTEST ( 0 )
117117 #ifdef TIMER0A
118118 #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
119119 PWM_CASE (0 , A );
@@ -122,20 +122,20 @@ static bool pwm_status(uint8_t pin) {
122122 PWM_CASE (0 , B );
123123 #endif
124124
125- #if defined( TCCR1A ) && defined( COM1A1 )
125+ #if ABTEST ( 1 )
126126 PWM_CASE (1 , A );
127127 PWM_CASE (1 , B );
128- #if defined(COM1C1 ) && defined(TIMER1C )
129- PWM_CASE (1 , C );
130- #endif
128+ #if defined(COM1C1 ) && defined(TIMER1C )
129+ PWM_CASE (1 , C );
130+ #endif
131131 #endif
132132
133- #if defined( TCCR2A ) && defined( COM2A1 )
133+ #if ABTEST ( 2 )
134134 PWM_CASE (2 , A );
135135 PWM_CASE (2 , B );
136136 #endif
137137
138- #if defined( TCCR3A ) && defined( COM3A1 )
138+ #if ABTEST ( 3 )
139139 PWM_CASE (3 , A );
140140 PWM_CASE (3 , B );
141141 #ifdef COM3C1
@@ -149,7 +149,7 @@ static bool pwm_status(uint8_t pin) {
149149 PWM_CASE (4 , C );
150150 #endif
151151
152- #if defined( TCCR5A ) && defined( COM5A1 )
152+ #if ABTEST ( 5 )
153153 PWM_CASE (5 , A );
154154 PWM_CASE (5 , B );
155155 PWM_CASE (5 , C );
@@ -166,16 +166,16 @@ static bool pwm_status(uint8_t pin) {
166166const volatile uint8_t * const PWM_other [][3 ] PROGMEM = {
167167 { & TCCR0A , & TCCR0B , & TIMSK0 },
168168 { & TCCR1A , & TCCR1B , & TIMSK1 },
169- #if defined( TCCR2A ) && defined ( COM2A1 )
169+ #if ABTEST ( 2 )
170170 { & TCCR2A , & TCCR2B , & TIMSK2 },
171171 #endif
172- #if defined( TCCR3A ) && defined ( COM3A1 )
172+ #if ABTEST ( 3 )
173173 { & TCCR3A , & TCCR3B , & TIMSK3 },
174174 #endif
175175 #ifdef TCCR4A
176176 { & TCCR4A , & TCCR4B , & TIMSK4 },
177177 #endif
178- #if defined( TCCR5A ) && defined ( COM5A1 )
178+ #if ABTEST ( 5 )
179179 { & TCCR5A , & TCCR5B , & TIMSK5 },
180180 #endif
181181};
@@ -195,11 +195,11 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
195195 { (const uint8_t * )& OCR1A , (const uint8_t * )& OCR1B , 0 },
196196 #endif
197197
198- #if defined( TCCR2A ) && defined ( COM2A1 )
198+ #if ABTEST ( 2 )
199199 { & OCR2A , & OCR2B , 0 },
200200 #endif
201201
202- #if defined( TCCR3A ) && defined ( COM3A1 )
202+ #if ABTEST ( 3 )
203203 #ifdef COM3C1
204204 { (const uint8_t * )& OCR3A , (const uint8_t * )& OCR3B , (const uint8_t * )& OCR3C },
205205 #else
@@ -211,7 +211,7 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
211211 { (const uint8_t * )& OCR4A , (const uint8_t * )& OCR4B , (const uint8_t * )& OCR4C },
212212 #endif
213213
214- #if defined( TCCR5A ) && defined ( COM5A1 )
214+ #if ABTEST ( 5 )
215215 { (const uint8_t * )& OCR5A , (const uint8_t * )& OCR5B , (const uint8_t * )& OCR5C },
216216 #endif
217217};
@@ -281,7 +281,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
281281static void pwm_details (uint8_t pin ) {
282282 switch (digitalPinToTimer_DEBUG (pin )) {
283283
284- #if defined( TCCR0A ) && defined( COM0A1 )
284+ #if ABTEST ( 0 )
285285 #ifdef TIMER0A
286286 #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
287287 case TIMER0A : timer_prefix (0 , 'A' , 3 ); break ;
@@ -290,20 +290,20 @@ static void pwm_details(uint8_t pin) {
290290 case TIMER0B : timer_prefix (0 , 'B' , 3 ); break ;
291291 #endif
292292
293- #if defined( TCCR1A ) && defined( COM1A1 )
293+ #if ABTEST ( 1 )
294294 case TIMER1A : timer_prefix (1 , 'A' , 4 ); break ;
295295 case TIMER1B : timer_prefix (1 , 'B' , 4 ); break ;
296296 #if defined(COM1C1 ) && defined(TIMER1C )
297297 case TIMER1C : timer_prefix (1 , 'C' , 4 ); break ;
298298 #endif
299299 #endif
300300
301- #if defined( TCCR2A ) && defined( COM2A1 )
301+ #if ABTEST ( 2 )
302302 case TIMER2A : timer_prefix (2 , 'A' , 3 ); break ;
303303 case TIMER2B : timer_prefix (2 , 'B' , 3 ); break ;
304304 #endif
305305
306- #if defined( TCCR3A ) && defined( COM3A1 )
306+ #if ABTEST ( 3 )
307307 case TIMER3A : timer_prefix (3 , 'A' , 4 ); break ;
308308 case TIMER3B : timer_prefix (3 , 'B' , 4 ); break ;
309309 #ifdef COM3C1
@@ -317,7 +317,7 @@ static void pwm_details(uint8_t pin) {
317317 case TIMER4C : timer_prefix (4 , 'C' , 4 ); break ;
318318 #endif
319319
320- #if defined( TCCR5A ) && defined( COM5A1 )
320+ #if ABTEST ( 5 )
321321 case TIMER5A : timer_prefix (5 , 'A' , 4 ); break ;
322322 case TIMER5B : timer_prefix (5 , 'B' , 4 ); break ;
323323 case TIMER5C : timer_prefix (5 , 'C' , 4 ); break ;
@@ -351,7 +351,6 @@ static void pwm_details(uint8_t pin) {
351351 #endif
352352} // pwm_details
353353
354-
355354#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
356355 int digitalRead_mod (const int8_t pin ) { // same as digitalRead except the PWM stop section has been removed
357356 const uint8_t port = digitalPinToPort_DEBUG (pin );
@@ -397,3 +396,5 @@ static void pwm_details(uint8_t pin) {
397396
398397#define PRINT_PIN (p ) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
399398#define PRINT_PIN_ANALOG (p ) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
399+
400+ #undef ABTEST
0 commit comments