|
|
|
@ -102,7 +102,7 @@ void PRINT_ARRAY_NAME(uint8_t x) {
|
|
|
|
|
return true; \
|
|
|
|
|
} else return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ABTEST(N) defined(TCCR##N##A) && defined(COM##N##A1)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Print a pin's PWM status.
|
|
|
|
@ -113,7 +113,7 @@ static bool pwm_status(uint8_t pin) {
|
|
|
|
|
|
|
|
|
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR0A) && defined(COM0A1)
|
|
|
|
|
#if ABTEST(0)
|
|
|
|
|
#ifdef TIMER0A
|
|
|
|
|
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
|
|
|
|
PWM_CASE(0, A);
|
|
|
|
@ -122,20 +122,20 @@ static bool pwm_status(uint8_t pin) {
|
|
|
|
|
PWM_CASE(0, B);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR1A) && defined(COM1A1)
|
|
|
|
|
#if ABTEST(1)
|
|
|
|
|
PWM_CASE(1, A);
|
|
|
|
|
PWM_CASE(1, B);
|
|
|
|
|
#if defined(COM1C1) && defined(TIMER1C)
|
|
|
|
|
PWM_CASE(1, C);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(COM1C1) && defined(TIMER1C)
|
|
|
|
|
PWM_CASE(1, C);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR2A) && defined(COM2A1)
|
|
|
|
|
#if ABTEST(2)
|
|
|
|
|
PWM_CASE(2, A);
|
|
|
|
|
PWM_CASE(2, B);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR3A) && defined(COM3A1)
|
|
|
|
|
#if ABTEST(3)
|
|
|
|
|
PWM_CASE(3, A);
|
|
|
|
|
PWM_CASE(3, B);
|
|
|
|
|
#ifdef COM3C1
|
|
|
|
@ -149,7 +149,7 @@ static bool pwm_status(uint8_t pin) {
|
|
|
|
|
PWM_CASE(4, C);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR5A) && defined(COM5A1)
|
|
|
|
|
#if ABTEST(5)
|
|
|
|
|
PWM_CASE(5, A);
|
|
|
|
|
PWM_CASE(5, B);
|
|
|
|
|
PWM_CASE(5, C);
|
|
|
|
@ -166,16 +166,16 @@ static bool pwm_status(uint8_t pin) {
|
|
|
|
|
const volatile uint8_t* const PWM_other[][3] PROGMEM = {
|
|
|
|
|
{ &TCCR0A, &TCCR0B, &TIMSK0 },
|
|
|
|
|
{ &TCCR1A, &TCCR1B, &TIMSK1 },
|
|
|
|
|
#if defined(TCCR2A) && defined(COM2A1)
|
|
|
|
|
#if ABTEST(2)
|
|
|
|
|
{ &TCCR2A, &TCCR2B, &TIMSK2 },
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(TCCR3A) && defined(COM3A1)
|
|
|
|
|
#if ABTEST(3)
|
|
|
|
|
{ &TCCR3A, &TCCR3B, &TIMSK3 },
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef TCCR4A
|
|
|
|
|
{ &TCCR4A, &TCCR4B, &TIMSK4 },
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(TCCR5A) && defined(COM5A1)
|
|
|
|
|
#if ABTEST(5)
|
|
|
|
|
{ &TCCR5A, &TCCR5B, &TIMSK5 },
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
@ -195,11 +195,11 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
|
|
|
|
{ (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 },
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR2A) && defined(COM2A1)
|
|
|
|
|
#if ABTEST(2)
|
|
|
|
|
{ &OCR2A, &OCR2B, 0 },
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR3A) && defined(COM3A1)
|
|
|
|
|
#if ABTEST(3)
|
|
|
|
|
#ifdef COM3C1
|
|
|
|
|
{ (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C },
|
|
|
|
|
#else
|
|
|
|
@ -211,7 +211,7 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
|
|
|
|
{ (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C },
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR5A) && defined(COM5A1)
|
|
|
|
|
#if ABTEST(5)
|
|
|
|
|
{ (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C },
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
@ -281,7 +281,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
|
|
|
|
static void pwm_details(uint8_t pin) {
|
|
|
|
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR0A) && defined(COM0A1)
|
|
|
|
|
#if ABTEST(0)
|
|
|
|
|
#ifdef TIMER0A
|
|
|
|
|
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
|
|
|
|
case TIMER0A: timer_prefix(0, 'A', 3); break;
|
|
|
|
@ -290,7 +290,7 @@ static void pwm_details(uint8_t pin) {
|
|
|
|
|
case TIMER0B: timer_prefix(0, 'B', 3); break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR1A) && defined(COM1A1)
|
|
|
|
|
#if ABTEST(1)
|
|
|
|
|
case TIMER1A: timer_prefix(1, 'A', 4); break;
|
|
|
|
|
case TIMER1B: timer_prefix(1, 'B', 4); break;
|
|
|
|
|
#if defined(COM1C1) && defined(TIMER1C)
|
|
|
|
@ -298,12 +298,12 @@ static void pwm_details(uint8_t pin) {
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR2A) && defined(COM2A1)
|
|
|
|
|
#if ABTEST(2)
|
|
|
|
|
case TIMER2A: timer_prefix(2, 'A', 3); break;
|
|
|
|
|
case TIMER2B: timer_prefix(2, 'B', 3); break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR3A) && defined(COM3A1)
|
|
|
|
|
#if ABTEST(3)
|
|
|
|
|
case TIMER3A: timer_prefix(3, 'A', 4); break;
|
|
|
|
|
case TIMER3B: timer_prefix(3, 'B', 4); break;
|
|
|
|
|
#ifdef COM3C1
|
|
|
|
@ -317,7 +317,7 @@ static void pwm_details(uint8_t pin) {
|
|
|
|
|
case TIMER4C: timer_prefix(4, 'C', 4); break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(TCCR5A) && defined(COM5A1)
|
|
|
|
|
#if ABTEST(5)
|
|
|
|
|
case TIMER5A: timer_prefix(5, 'A', 4); break;
|
|
|
|
|
case TIMER5B: timer_prefix(5, 'B', 4); break;
|
|
|
|
|
case TIMER5C: timer_prefix(5, 'C', 4); break;
|
|
|
|
@ -351,7 +351,6 @@ static void pwm_details(uint8_t pin) {
|
|
|
|
|
#endif
|
|
|
|
|
} // pwm_details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
|
|
|
|
int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed
|
|
|
|
|
const uint8_t port = digitalPinToPort_DEBUG(pin);
|
|
|
|
@ -397,3 +396,5 @@ static void pwm_details(uint8_t pin) {
|
|
|
|
|
|
|
|
|
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
|
|
|
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
|
|
|
|
|
|
|
|
|
#undef ABTEST
|
|
|
|
|