Unify AVR90USB: pinsDebug changes

This commit is contained in:
Scott Lahteine 2017-06-08 18:08:30 -05:00
parent 5426fc1735
commit 748bf32388
4 changed files with 235 additions and 132 deletions

View File

@ -732,9 +732,7 @@ void report_current_position_detail();
SERIAL_ECHOPAIR(", ", y);
SERIAL_ECHOPAIR(", ", z);
SERIAL_CHAR(')');
if (suffix) {serialprintPGM(suffix);} //won't compile for Teensy with the previous construction
else SERIAL_EOL();
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}
void print_xyz(const char* prefix, const char* suffix, const float xyz[]) {
@ -6366,23 +6364,44 @@ inline void gcode_M42() {
wait = parser.seen('W') ? parser.value_int() : 500;
for (uint8_t pin = start; pin <= end; pin++) {
//report_pin_state_extended(pin, I_flag, false);
if (!I_flag && pin_is_protected(pin)) {
SERIAL_ECHOPAIR("Sensitive Pin: ", pin);
SERIAL_ECHOLNPGM(" untouched.");
report_pin_state_extended(pin, I_flag, true, "Untouched ");
SERIAL_EOL();
}
else {
SERIAL_ECHOPAIR("Pulsing Pin: ", pin);
pinMode(pin, OUTPUT);
for (int16_t j = 0; j < repeat; j++) {
digitalWrite(pin, 0);
safe_delay(wait);
digitalWrite(pin, 1);
safe_delay(wait);
digitalWrite(pin, 0);
safe_delay(wait);
report_pin_state_extended(pin, I_flag, true, "Pulsing ");
#ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46) {
SET_OUTPUT(46);
for (int16_t j = 0; j < repeat; j++) {
WRITE(46, 0); safe_delay(wait);
WRITE(46, 1); safe_delay(wait);
WRITE(46, 0); safe_delay(wait);
}
}
else if (pin == 47) {
SET_OUTPUT(47);
for (int16_t j = 0; j < repeat; j++) {
WRITE(47, 0); safe_delay(wait);
WRITE(47, 1); safe_delay(wait);
WRITE(47, 0); safe_delay(wait);
}
}
else
#endif
{
pinMode(pin, OUTPUT);
for (int16_t j = 0; j < repeat; j++) {
digitalWrite(pin, 0); safe_delay(wait);
digitalWrite(pin, 1); safe_delay(wait);
digitalWrite(pin, 0); safe_delay(wait);
}
}
}
SERIAL_CHAR('\n');
SERIAL_EOL();
}
SERIAL_ECHOLNPGM("Done.");
@ -6527,13 +6546,13 @@ inline void gcode_M42() {
* M43 E<bool> - Enable / disable background endstop monitoring
* - Machine continues to operate
* - Reports changes to endstops
* - Toggles LED when an endstop changes
* - Toggles LED_PIN when an endstop changes
* - Can not reliably catch the 5mS pulse from BLTouch type probes
*
* M43 T - Toggle pin(s) and report which pin is being toggled
* S<pin> - Start Pin number. If not given, will default to 0
* L<pin> - End Pin number. If not given, will default to last pin defined for this board
* I - Flag to ignore Marlin's pin protection. Use with caution!!!!
* I<bool> - Flag to ignore Marlin's pin protection. Use with caution!!!!
* R - Repeat pulses on each pin this number of times before continueing to next pin
* W - Wait time (in miliseconds) between pulses. If not given will default to 500
*
@ -6542,7 +6561,7 @@ inline void gcode_M42() {
*/
inline void gcode_M43() {
if (parser.seen('T')) { // must be first ot else it's "S" and "E" parameters will execute endstop or servo test
if (parser.seen('T')) { // must be first or else it's "S" and "E" parameters will execute endstop or servo test
toggle_pins();
return;
}
@ -6576,6 +6595,7 @@ inline void gcode_M42() {
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
if (pin_is_protected(pin) && !ignore_protection) continue;
pinMode(pin, INPUT_PULLUP);
delay(1);
/*
if (IS_ANALOG(pin))
pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
@ -6591,7 +6611,7 @@ inline void gcode_M42() {
for (;;) {
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
if (pin_is_protected(pin)) continue;
if (pin_is_protected(pin) && !ignore_protection) continue;
const byte val =
/*
IS_ANALOG(pin)
@ -6600,7 +6620,7 @@ inline void gcode_M42() {
//*/
digitalRead(pin);
if (val != pin_state[pin - first_pin]) {
report_pin_state(pin);
report_pin_state_extended(pin, ignore_protection, false);
pin_state[pin - first_pin] = val;
}
}
@ -6612,14 +6632,14 @@ inline void gcode_M42() {
}
#endif
safe_delay(500);
safe_delay(200);
}
return;
}
// Report current state of selected pin(s)
for (uint8_t pin = first_pin; pin <= last_pin; pin++)
report_pin_state_extended(pin, ignore_protection);
report_pin_state_extended(pin, ignore_protection, true);
}
#endif // PINS_DEBUGGING
@ -12164,7 +12184,9 @@ void prepare_move_to_destination() {
val &= 0x07;
switch (digitalPinToTimer(pin)) {
#ifdef TCCR0A
case TIMER0A:
#if !AVR_AT90USB1286_FAMILY
case TIMER0A:
#endif
case TIMER0B:
//_SET_CS(0, val);
break;

View File

@ -20,18 +20,13 @@
*
*/
bool endstop_monitor_flag = false;
#define NAME_FORMAT "%-28s" // one place to specify the format of all the sources of names
#define NAME_FORMAT "%-35s" // one place to specify the format of all the sources of names
// "-" left justify, "28" minimum width of name, pad with blanks
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7)))
#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
/**
* This routine minimizes RAM usage by creating a FLASH resident array to
* store the pin names, pin numbers and analog/digital flag.
@ -52,7 +47,7 @@ bool endstop_monitor_flag = false;
#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
#include "pinsDebug_list.h"
#line 56
#line 51
// manually add pins that have names that are macros which don't play well with these macros
#if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY)
@ -88,27 +83,34 @@ const char* const pin_array[][3] PROGMEM = {
// manually add pins ...
#if SERIAL_PORT == 0
#if AVR_ATmega2560_FAMILY
{ RXD_NAME, "0", "1" },
{ TXD_NAME, "1", "1" },
{ RXD_NAME, 0, 1 },
{ TXD_NAME, 1, 1 },
#elif AVR_ATmega1284_FAMILY
{ RXD_NAME, "8", "1" },
{ TXD_NAME, "9", "1" },
{ RXD_NAME, 8, 1 },
{ TXD_NAME, 9, 1 },
#endif
#endif
#include "pinsDebug_list.h"
#line 101
#line 96
};
#define n_array (sizeof(pin_array) / sizeof(char*)) / 3
#ifndef TIMER1B
// working with Teensyduino extension so need to re-define some things
#if AVR_AT90USB1286_FAMILY
// Working with Teensyduino extension so need to re-define some things
#include "pinsDebug_Teensyduino.h"
// Can't use the "digitalPinToPort" function from the Teensyduino type IDEs
// portModeRegister takes a different argument
#define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p)
#define get_pinMode(pin) (*portModeRegister(pin) & digitalPinToBitMask(pin))
#else
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
bool get_pinMode(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask(pin); }
#endif
#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
#define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM: %4d"), V); SERIAL_ECHO(buffer); }while(0)
#define PWM_CASE(N,Z) \
case TIMER##N##Z: \
if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
@ -127,7 +129,9 @@ static bool pwm_status(uint8_t pin) {
#if defined(TCCR0A) && defined(COM0A1)
#ifdef TIMER0A
PWM_CASE(0, A);
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
PWM_CASE(0, A);
#endif
#endif
PWM_CASE(0, B);
#endif
@ -244,9 +248,10 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
static void err_is_counter() { SERIAL_PROTOCOLPGM(" non-standard PWM mode"); }
static void err_is_interrupt() { SERIAL_PROTOCOLPGM(" compare interrupt enabled"); }
static void err_prob_interrupt() { SERIAL_PROTOCOLPGM(" overflow interrupt enabled"); }
static void print_is_also_tied() { SERIAL_PROTOCOLPGM(" is also tied to this pin"); SERIAL_PROTOCOL_SP(14); }
void com_print(uint8_t N, uint8_t Z) {
uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_PROTOCOLPGM(" COM");
SERIAL_PROTOCOLCHAR(N + '0');
switch (Z) {
@ -264,8 +269,8 @@ void com_print(uint8_t N, uint8_t Z) {
void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout
char buffer[20]; // for the sprintf statements
uint8_t *TCCRB = (uint8_t*)TCCR_B(T);
uint8_t *TCCRA = (uint8_t*)TCCR_A(T);
const uint8_t *TCCRB = (uint8_t*)TCCR_B(T),
*TCCRA = (uint8_t*)TCCR_A(T);
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
@ -275,11 +280,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
SERIAL_PROTOCOL_SP(3);
if (N == 3) {
uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
const uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
PWM_PRINT(*OCRVAL8);
}
else {
uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A');
const uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A');
PWM_PRINT(*OCRVAL16);
}
SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
@ -294,12 +299,12 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
SERIAL_PROTOCOLCHAR(T + '0');
SERIAL_PROTOCOLPAIR("B: ", *TCCRB);
uint8_t *TMSK = (uint8_t*)TIMSK(T);
const uint8_t *TMSK = (uint8_t*)TIMSK(T);
SERIAL_PROTOCOLPGM(" TIMSK");
SERIAL_PROTOCOLCHAR(T + '0');
SERIAL_PROTOCOLPAIR(": ", *TMSK);
uint8_t OCIE = L - 'A' + 1;
const uint8_t OCIE = L - 'A' + 1;
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
else { if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter(); }
if (TEST(*TMSK, OCIE)) err_is_interrupt();
@ -311,7 +316,9 @@ static void pwm_details(uint8_t pin) {
#if defined(TCCR0A) && defined(COM0A1)
#ifdef TIMER0A
case TIMER0A: timer_prefix(0, 'A', 3); break;
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
case TIMER0A: timer_prefix(0, 'A', 3); break;
#endif
#endif
case TIMER0B: timer_prefix(0, 'B', 3); break;
#endif
@ -357,136 +364,192 @@ static void pwm_details(uint8_t pin) {
// on pins that have two PWMs, print info on second PWM
#if AVR_ATmega2560_FAMILY || AVR_AT90USB1286_FAMILY
// looking for port B7 - PWMs 0A and 1C
if (digitalPinToPort(pin) == 2 && digitalPinToBitMask(pin) == 0x80) {
#ifndef TEENSYDUINO_IDE
if (digitalPinToPort_DEBUG(pin) == 'B' - 64 && 0x80 == digitalPinToBitMask(pin)) {
#if !AVR_AT90USB1286_FAMILY
SERIAL_PROTOCOLPGM("\n .");
SERIAL_PROTOCOL_SP(18);
SERIAL_PROTOCOLPGM("TIMER1C is also tied to this pin");
SERIAL_PROTOCOL_SP(13);
SERIAL_PROTOCOLPGM("TIMER1C");
print_is_also_tied();
timer_prefix(1, 'C', 4);
#else
SERIAL_PROTOCOLPGM("\n .");
SERIAL_PROTOCOL_SP(18);
SERIAL_PROTOCOLPGM("TIMER0A is also tied to this pin");
SERIAL_PROTOCOL_SP(13);
SERIAL_PROTOCOLPGM("TIMER0A");
print_is_also_tied();
timer_prefix(0, 'A', 3);
#endif
}
#endif
} // pwm_details
bool get_pinMode(int8_t pin) { return *portModeRegister(digitalPinToPort(pin)) & digitalPinToBitMask(pin); }
#ifndef digitalRead_mod // use Teensyduino's version of digitalRead - it doesn't disable the PWMs
int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed
uint8_t port = digitalPinToPort(pin);
#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);
return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW;
}
#endif
void print_port(int8_t pin) { // print port number
#ifdef digitalPinToPort
#ifdef digitalPinToPort_DEBUG
uint8_t x;
SERIAL_PROTOCOLPGM(" Port: ");
uint8_t x = digitalPinToPort(pin) + 64;
#if AVR_AT90USB1286_FAMILY
x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64;
#else
x = digitalPinToPort_DEBUG(pin) + 64;
#endif
SERIAL_CHAR(x);
uint8_t temp = digitalPinToBitMask(pin);
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
#if AVR_AT90USB1286_FAMILY
if (pin == 46)
x = '2';
else if (pin == 47)
x = '3';
else {
uint8_t temp = digitalPinToBitMask(pin);
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
}
#else
uint8_t temp = digitalPinToBitMask(pin);
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
#endif
SERIAL_CHAR(x);
#else
SERIAL_PROTOCOL_SP(10);
#endif
}
static void print_input_or_output(const bool isout) {
serialprintPGM(isout ? PSTR("Output = ") : PSTR("Input = "));
}
// pretty report with PWM info
inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = true) {
inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = false,const char *start_string = "") {
uint8_t temp_char;
char *name_mem_pointer;
char buffer[30]; // for the sprintf statements
bool found = false,
multi_name_pin = false;
char *name_mem_pointer, buffer[30]; // for the sprintf statements
bool found = false, multi_name_pin = false;
for (uint8_t x = 0; x < n_array; x++) { // scan entire array and report all instances of this pin
if (pgm_read_byte(&pin_array[x][1]) == pin) {
if (found) multi_name_pin = true;
found = true;
if (!multi_name_pin) { // report digitial and analog pin number only on the first time through
sprintf(buffer, "PIN: %3d ", pin); // digital pin number
sprintf_P(buffer, PSTR("%sPIN: %3d "), start_string, pin); // digital pin number
SERIAL_ECHO(buffer);
print_port(pin);
if (IS_ANALOG(pin)) {
sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number
sprintf_P(buffer, PSTR(" (A%2d) "), int(pin - analogInputToDigitalPin(0))); // analog pin number
SERIAL_ECHO(buffer);
}
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
}
else {
SERIAL_CHAR('.');
SERIAL_ECHO_SP(25); // add padding if not the first instance found
SERIAL_ECHO_SP(26 + strlen(start_string)); // add padding if not the first instance found
}
name_mem_pointer = (char*)pgm_read_word(&pin_array[x][0]);
for (uint8_t y = 0; y < 28; y++) { // always print pin name
temp_char = pgm_read_byte(name_mem_pointer + y);
if (temp_char != 0) MYSERIAL.write(temp_char);
if (temp_char != 0)
MYSERIAL.write(temp_char);
else {
for (uint8_t i = 0; i < 28 - y; i++) MYSERIAL.write(' ');
break;
}
}
if (pin_is_protected(pin) && !ignore)
SERIAL_ECHOPGM("protected ");
else {
if (!(pgm_read_byte(&pin_array[x][2]))) {
sprintf(buffer, "Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0)));
SERIAL_ECHO(buffer);
}
if (extended) {
if (pin_is_protected(pin) && !ignore)
SERIAL_ECHOPGM("protected ");
else {
if (!get_pinMode(pin)) {
//pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this
// because this could interfere with inductive/capacitive
// sensors (high impedance voltage divider) and with PT100 amplifier
SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
#ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46) {
print_input_or_output(GET_OUTPUT(46));
SERIAL_PROTOCOL(READ(46));
}
else if (pin == 47)
print_input_or_output(GET_OUTPUT(47));
SERIAL_PROTOCOL(READ(47));
}
else
#endif
{
if (!(pgm_read_byte(&pin_array[x][2]))) {
sprintf_P(buffer, PSTR("Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
SERIAL_ECHO(buffer);
}
else {
if (!get_pinMode(pin)) {
//pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this
// because this could interfere with inductive/capacitive
// sensors (high impedance voltage divider) and with PT100 amplifier
print_input_or_output(false);
SERIAL_PROTOCOL(digitalRead_mod(pin));
}
else if (pwm_status(pin)) {
// do nothing
}
else {
print_input_or_output(true);
SERIAL_PROTOCOL(digitalRead_mod(pin));
}
}
if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report
}
else if (pwm_status(pin)) {
// do nothing
}
else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
}
if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report
}
SERIAL_EOL();
} // end of IF
} // end of for loop
if (!found) {
sprintf(buffer, "PIN: %3d ", pin);
sprintf_P(buffer, PSTR("%sPIN: %3d "), start_string, pin);
SERIAL_ECHO(buffer);
print_port(pin);
if (IS_ANALOG(pin)) {
sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number
sprintf_P(buffer, PSTR(" (A%2d) "), int(pin - analogInputToDigitalPin(0))); // analog pin number
SERIAL_ECHO(buffer);
}
else
SERIAL_ECHO_SP(8); // add padding if not an analog pin
SERIAL_ECHOPGM("<unused/unknown>");
if (get_pinMode(pin)) {
SERIAL_PROTOCOL_SP(12);
SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
}
else {
if (IS_ANALOG(pin)) {
sprintf(buffer, " Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0)));
SERIAL_ECHO(buffer);
}
else
SERIAL_ECHO_SP(9); // add padding if not an analog pin
SERIAL_ECHO_SP(8); // add padding if not an analog pin
SERIAL_ECHOPGM("<unused/unknown>");
if (extended) {
#ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46 || pin == 47) {
SERIAL_PROTOCOL_SP(12);
if (pin == 46) {
print_input_or_output(GET_OUTPUT(46));
SERIAL_PROTOCOL(READ(46));
}
else {
print_input_or_output(GET_OUTPUT(47));
SERIAL_PROTOCOL(READ(47));
}
}
else
#endif
{
if (get_pinMode(pin)) {
SERIAL_PROTOCOL_SP(12);
print_input_or_output(true);
SERIAL_PROTOCOL(digitalRead_mod(pin));
}
else {
if (IS_ANALOG(pin)) {
sprintf_P(buffer, PSTR(" Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
SERIAL_ECHO(buffer);
SERIAL_ECHOPGM(" ");
}
else
SERIAL_ECHO_SP(12); // add padding if not an analog pin
SERIAL_PROTOCOLPAIR(" Input = ", digitalRead_mod(pin));
print_input_or_output(false);
SERIAL_PROTOCOL(digitalRead_mod(pin));
}
//if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report
}
}
SERIAL_EOL();
}
//if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report
SERIAL_EOL();
}
}
inline void report_pin_state(int8_t pin) {
report_pin_state_extended(pin, false, false);
}

View File

@ -25,21 +25,16 @@
// do not function the same as the other Arduino extensions
//
#ifndef __PINSDEBUG_TEENSYDUINO_H__
#define __PINSDEBUG_TEENSYDUINO_H__
#define TEENSYDUINO_IDE
#undef NUM_DIGITAL_PINS
#define NUM_DIGITAL_PINS 48 // Teensy says 46 but FASTIO is 48
//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
#define TIMER0B 1
#define TIMER1A 7
#define TIMER1B 8
#define TIMER1C 9
#define TIMER2A 6
#define TIMER2B 2
#define TIMER3A 5
#define TIMER3B 4
#define TIMER3C 3
// "digitalPinToPort" function just returns the pin number so need to create our own.
// Can't use the name "digitalPinToPort" for our own because it interferes with the
// FAST_PWM_FAN function if we do
// digitalPinToPort function just returns the pin number so need to create our own
#define PA 1
#define PB 2
#define PC 3
@ -47,9 +42,8 @@
#define PE 5
#define PF 6
#undef digitalPinToPort
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
const uint8_t PROGMEM digital_pin_to_port_PGM_Teensy[] = {
PD, // 0 - PD0 - INT0 - PWM
PD, // 1 - PD1 - INT1 - PWM
PD, // 2 - PD2 - INT2 - RX
@ -100,7 +94,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
PE, // 47 - PE3 (not defined in teensyduino)
};
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
#define digitalPinToPort_Teensy(P) ( pgm_read_byte( digital_pin_to_port_PGM_Teensy + (P) ) )
// digitalPinToBitMask(pin) is OK
@ -108,3 +102,5 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
// disable the PWMs so we can use it as is
// portModeRegister(pin) is OK
#endif // __PINSDEBUG_TEENSYDUINO_H__

View File

@ -353,22 +353,22 @@
#if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0
REPORT_NAME_DIGITAL(LCD_CONTRAST, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0
REPORT_NAME_DIGITAL(LCD_PINS_D4, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_D5) && LCD_PINS_D5 >= 0
REPORT_NAME_DIGITAL(LCD_PINS_D5, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_D6) && LCD_PINS_D6 >= 0
REPORT_NAME_DIGITAL(LCD_PINS_D6, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_D7) && LCD_PINS_D7 >= 0
REPORT_NAME_DIGITAL(LCD_PINS_D7, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0
REPORT_NAME_DIGITAL(LCD_PINS_ENABLE, __LINE__ )
#endif
#if PIN_EXISTS(LCD)
#if defined(LCD_PINS_RS) && LCD_PINS_RS >= 0
REPORT_NAME_DIGITAL(LCD_PINS_RS, __LINE__ )
#endif
#if defined(LCD_SDSS) && LCD_SDSS >= 0
@ -446,6 +446,18 @@
#if PIN_EXISTS(RAMPS_D9)
REPORT_NAME_DIGITAL(RAMPS_D9_PIN, __LINE__ )
#endif
#if PIN_EXISTS(RGB_LED_R)
REPORT_NAME_DIGITAL(RGB_LED_R_PIN, __LINE__ )
#endif
#if PIN_EXISTS(RGB_LED_G)
REPORT_NAME_DIGITAL(RGB_LED_G_PIN, __LINE__ )
#endif
#if PIN_EXISTS(RGB_LED_B)
REPORT_NAME_DIGITAL(RGB_LED_B_PIN, __LINE__ )
#endif
#if PIN_EXISTS(RGB_LED_W)
REPORT_NAME_DIGITAL(RGB_LED_W_PIN, __LINE__ )
#endif
#if PIN_EXISTS(RX_ENABLE)
REPORT_NAME_DIGITAL(RX_ENABLE_PIN, __LINE__ )
#endif
@ -500,12 +512,21 @@
#if PIN_EXISTS(SLEEP_WAKE)
REPORT_NAME_DIGITAL(SLEEP_WAKE_PIN, __LINE__ )
#endif
#if PIN_EXISTS(SOL0)
REPORT_NAME_DIGITAL(SOL0_PIN, __LINE__ )
#endif
#if PIN_EXISTS(SOL1)
REPORT_NAME_DIGITAL(SOL1_PIN, __LINE__ )
#endif
#if PIN_EXISTS(SOL2)
REPORT_NAME_DIGITAL(SOL2_PIN, __LINE__ )
#endif
#if PIN_EXISTS(SOL3)
REPORT_NAME_DIGITAL(SOL3_PIN, __LINE__ )
#endif
#if PIN_EXISTS(SOL4)
REPORT_NAME_DIGITAL(SOL4_PIN, __LINE__ )
#endif
#if defined(SPARE_IO) && SPARE_IO >= 0
REPORT_NAME_DIGITAL(SPARE_IO, __LINE__ )
#endif
@ -749,3 +770,4 @@
#if PIN_EXISTS(Z2_STEP)
REPORT_NAME_DIGITAL(Z2_STEP_PIN, __LINE__ )
#endif