2 bug fixes & some minor changes

see detailed  description in PR #5118
This commit is contained in:
Bob-the-Kuhn 2016-10-31 13:56:14 -05:00 committed by Scott Lahteine
parent fa6bf12697
commit c20b4098be

View File

@ -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; }
#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
PIN_SAY(__FD)
#endif
@ -656,10 +656,10 @@ static bool report_pin_name(int8_t pin, bool &pin_is_analog) {
} // report_pin_name
#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
#define PWM_CASE(N) \
case TIMER##N: \
if (TCCR##N & (_BV(COM## N ##1) | _BV(COM## N ##0))) { \
PWM_PRINT(OCR##N); \
#define PWM_CASE(N,Z) \
case TIMER##N##Z: \
if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
PWM_PRINT(OCR##N##Z); \
return true; \
} 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.
* 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
switch(digitalPinToTimer(pin)) {
#if defined(TCCR0A) && defined(COM0A1)
PWM_CASE(0A);
PWM_CASE(0B);
PWM_CASE(0,A);
PWM_CASE(0,B);
#endif
#if defined(TCCR1A) && defined(COM1A1)
PWM_CASE(1A);
PWM_CASE(1B);
PWM_CASE(1C);
PWM_CASE(1,A);
PWM_CASE(1,B);
PWM_CASE(1,C);
#endif
#if defined(TCCR2A) && defined(COM2A1)
PWM_CASE(2A);
PWM_CASE(2B);
PWM_CASE(2,A);
PWM_CASE(2,B);
#endif
#if defined(TCCR3A) && defined(COM3A1)
PWM_CASE(3A);
PWM_CASE(3B);
PWM_CASE(3C);
PWM_CASE(3,A);
PWM_CASE(3,B);
PWM_CASE(3,C);
#endif
#ifdef TCCR4A
PWM_CASE(4A);
PWM_CASE(4B);
PWM_CASE(4C);
PWM_CASE(4,A);
PWM_CASE(4,B);
PWM_CASE(4,C);
#endif
#if defined(TCCR5A) && defined(COM5A1)
PWM_CASE(5A);
PWM_CASE(5B);
PWM_CASE(5C);
PWM_CASE(5,A);
PWM_CASE(5,B);
PWM_CASE(5,C);
#endif
case NOT_ON_TIMER:
@ -711,10 +711,10 @@ static bool PWM_status(uint8_t pin) {
return false;
}
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_MAKE4(N) (WGM_MAKE3(N) | (TEST(TCCR##N##B, WGM##N##3) >> 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) | (TCCR##N##B & _BV(WGM##N##3)) >> 1)
#define TIMER_PREFIX(T,L,N) do{ \
WGM = WGM_MAKE##N(T); \
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 PWM_details(uint8_t pin) {
static void pwm_details(uint8_t pin) {
uint8_t WGM;
@ -885,9 +885,7 @@ static void PWM_details(uint8_t pin) {
}
SERIAL_PROTOCOLPGM(" ");
} // PWM_details
} // pwm_details
inline void report_pin_state(int8_t 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
SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
}
else if (PWM_status(pin)) {
else if (pwm_status(pin)) {
// do nothing
}
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
PWM_details(pin);
pwm_details(pin);
SERIAL_EOL;
}