Merge pull request #5132 from thinkyhead/rc_fix_M43
Followup to #5118 - pins debugging cleanup
This commit is contained in:
commit
9c108aea18
@ -60,7 +60,7 @@ static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
|
|||||||
if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; }
|
if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Pin list updated from 7 OCT RCBugfix branch
|
// Pin list updated from 7 OCT RCBugfix branch - max length of pin name is 24
|
||||||
#if defined(__FD) && __FD >= 0
|
#if defined(__FD) && __FD >= 0
|
||||||
PIN_SAY(__FD)
|
PIN_SAY(__FD)
|
||||||
#endif
|
#endif
|
||||||
@ -656,10 +656,10 @@ static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
|
|||||||
} // report_pin_name
|
} // report_pin_name
|
||||||
|
|
||||||
#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
|
#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PWM_CASE(N) \
|
#define PWM_CASE(N,Z) \
|
||||||
case TIMER##N: \
|
case TIMER##N##Z: \
|
||||||
if (TCCR##N & (_BV(COM## N ##1) | _BV(COM## N ##0))) { \
|
if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
|
||||||
PWM_PRINT(OCR##N); \
|
PWM_PRINT(OCR##N##Z); \
|
||||||
return true; \
|
return true; \
|
||||||
} else return false
|
} else return false
|
||||||
|
|
||||||
@ -667,43 +667,43 @@ static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
|
|||||||
* Print a pin's PWM status.
|
* Print a pin's PWM status.
|
||||||
* Return true if it's currently a PWM pin.
|
* Return true if it's currently a PWM pin.
|
||||||
*/
|
*/
|
||||||
static bool PWM_status(uint8_t pin) {
|
static bool pwm_status(uint8_t pin) {
|
||||||
char buffer[20]; // for the sprintf statements
|
char buffer[20]; // for the sprintf statements
|
||||||
|
|
||||||
switch(digitalPinToTimer(pin)) {
|
switch(digitalPinToTimer(pin)) {
|
||||||
|
|
||||||
#if defined(TCCR0A) && defined(COM0A1)
|
#if defined(TCCR0A) && defined(COM0A1)
|
||||||
PWM_CASE(0A);
|
PWM_CASE(0,A);
|
||||||
PWM_CASE(0B);
|
PWM_CASE(0,B);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TCCR1A) && defined(COM1A1)
|
#if defined(TCCR1A) && defined(COM1A1)
|
||||||
PWM_CASE(1A);
|
PWM_CASE(1,A);
|
||||||
PWM_CASE(1B);
|
PWM_CASE(1,B);
|
||||||
PWM_CASE(1C);
|
PWM_CASE(1,C);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TCCR2A) && defined(COM2A1)
|
#if defined(TCCR2A) && defined(COM2A1)
|
||||||
PWM_CASE(2A);
|
PWM_CASE(2,A);
|
||||||
PWM_CASE(2B);
|
PWM_CASE(2,B);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TCCR3A) && defined(COM3A1)
|
#if defined(TCCR3A) && defined(COM3A1)
|
||||||
PWM_CASE(3A);
|
PWM_CASE(3,A);
|
||||||
PWM_CASE(3B);
|
PWM_CASE(3,B);
|
||||||
PWM_CASE(3C);
|
PWM_CASE(3,C);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TCCR4A
|
#ifdef TCCR4A
|
||||||
PWM_CASE(4A);
|
PWM_CASE(4,A);
|
||||||
PWM_CASE(4B);
|
PWM_CASE(4,B);
|
||||||
PWM_CASE(4C);
|
PWM_CASE(4,C);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TCCR5A) && defined(COM5A1)
|
#if defined(TCCR5A) && defined(COM5A1)
|
||||||
PWM_CASE(5A);
|
PWM_CASE(5,A);
|
||||||
PWM_CASE(5B);
|
PWM_CASE(5,B);
|
||||||
PWM_CASE(5C);
|
PWM_CASE(5,C);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case NOT_ON_TIMER:
|
case NOT_ON_TIMER:
|
||||||
@ -711,10 +711,10 @@ static bool PWM_status(uint8_t pin) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SERIAL_PROTOCOLPGM(" ");
|
SERIAL_PROTOCOLPGM(" ");
|
||||||
} //PWM_status
|
} // pwm_status
|
||||||
|
|
||||||
#define WGM_MAKE3(N) ((TEST(TCCR##N##B, WGM##N##2) >> 1) | (TCCR##N##A & (_BV(WGM##N##0) | _BV(WGM##N##1))))
|
#define WGM_MAKE3(N) (((TCCR##N##B & _BV(WGM##N##2)) >> 1) | (TCCR##N##A & (_BV(WGM##N##0) | _BV(WGM##N##1))))
|
||||||
#define WGM_MAKE4(N) (WGM_MAKE3(N) | (TEST(TCCR##N##B, WGM##N##3) >> 1))
|
#define WGM_MAKE4(N) (WGM_MAKE3(N) | (TCCR##N##B & _BV(WGM##N##3)) >> 1)
|
||||||
#define TIMER_PREFIX(T,L,N) do{ \
|
#define TIMER_PREFIX(T,L,N) do{ \
|
||||||
WGM = WGM_MAKE##N(T); \
|
WGM = WGM_MAKE##N(T); \
|
||||||
SERIAL_PROTOCOLPGM(" TIMER"); \
|
SERIAL_PROTOCOLPGM(" TIMER"); \
|
||||||
@ -745,7 +745,7 @@ static void err_prob_interrupt() {
|
|||||||
}
|
}
|
||||||
static void can_be_used() { SERIAL_PROTOCOLPGM(" can be used as PWM "); }
|
static void can_be_used() { SERIAL_PROTOCOLPGM(" can be used as PWM "); }
|
||||||
|
|
||||||
static void PWM_details(uint8_t pin) {
|
static void pwm_details(uint8_t pin) {
|
||||||
|
|
||||||
uint8_t WGM;
|
uint8_t WGM;
|
||||||
|
|
||||||
@ -885,9 +885,7 @@ static void PWM_details(uint8_t pin) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
SERIAL_PROTOCOLPGM(" ");
|
SERIAL_PROTOCOLPGM(" ");
|
||||||
} // PWM_details
|
} // pwm_details
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline void report_pin_state(int8_t pin) {
|
inline void report_pin_state(int8_t pin) {
|
||||||
SERIAL_ECHO((int)pin);
|
SERIAL_ECHO((int)pin);
|
||||||
@ -938,7 +936,7 @@ inline void report_pin_state_extended(int8_t pin, bool ignore) {
|
|||||||
pinMode(pin, INPUT_PULLUP); // make sure input isn't floating
|
pinMode(pin, INPUT_PULLUP); // make sure input isn't floating
|
||||||
SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
|
SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
|
||||||
}
|
}
|
||||||
else if (PWM_status(pin)) {
|
else if (pwm_status(pin)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
|
else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
|
||||||
@ -946,7 +944,7 @@ inline void report_pin_state_extended(int8_t pin, bool ignore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// report PWM capabilities
|
// report PWM capabilities
|
||||||
PWM_details(pin);
|
pwm_details(pin);
|
||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user