Browse Source
Re-ARM has been tested. AVR has not been tested. 1) moved all cpu specific items to files in the low level HAL directory for that CPU (pinDebug_Re-ARM.h & pinsDebug_AVR_8_bit.h 2) added pinsDebug.h to the top level directory 3) modified HAL_pinsDebug.h to select the correct support file for the selected CPU 4) Patched sanitycheck to stop throwing false errors. A long term solution will be done 5) misc changes & bug fixes arduino.cpp - included macros.h to fix a missing definition pinmap_re-arm.h - removed a duplicated line. pinmapping.h - changed from "ENABLED" to "defined" to fix a compile error ====================================================================== split SanityCheck up, improve pinsDebug system ====================================================================== switch to latest pins_RAMPS_RE_ARM.hpull/1/head
Bob-the-Kuhn
7 years ago
committed by
Scott Lahteine
17 changed files with 1151 additions and 434 deletions
@ -0,0 +1,102 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* Test AVR specific configuration values for errors at compile-time. |
|||
*/ |
|||
|
|||
/**
|
|||
* Require gcc 4.7 or newer (first included with Arduino 1.6.8) for C++11 features. |
|||
*/ |
|||
|
|||
|
|||
/**
|
|||
* Digipot requirement |
|||
*/ |
|||
#if ENABLED(DIGIPOT_MCP4018) |
|||
#if !defined(DIGIPOTS_I2C_SDA_X) || !defined(DIGIPOTS_I2C_SDA_Y) || !defined(DIGIPOTS_I2C_SDA_Z) \ |
|||
|| !defined(DIGIPOTS_I2C_SDA_E0) || !defined(DIGIPOTS_I2C_SDA_E1) |
|||
#error "DIGIPOT_MCP4018 requires DIGIPOTS_I2C_SDA_* pins to be defined." |
|||
#endif |
|||
#endif |
|||
|
|||
|
|||
|
|||
/**
|
|||
* Sanity checks for Spindle / Laser |
|||
*/ |
|||
|
|||
#if ENABLED(SPINDLE_LASER_ENABLE) |
|||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE) |
|||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN." |
|||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR) |
|||
#error "SPINDLE_DIR_PIN not defined." |
|||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM) |
|||
#if !(WITHIN(SPINDLE_LASER_PWM_PIN, 2, 13) || WITHIN(SPINDLE_LASER_PWM_PIN, 44, 46)) |
|||
#error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin." |
|||
#elif SPINDLE_LASER_POWERUP_DELAY < 1 |
|||
#error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0." |
|||
#elif SPINDLE_LASER_POWERDOWN_DELAY < 1 |
|||
#error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0." |
|||
#elif !defined(SPINDLE_LASER_PWM_INVERT) |
|||
#error "SPINDLE_LASER_PWM_INVERT missing." |
|||
#elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX) |
|||
#error "SPINDLE_LASER_PWM equation constant(s) missing." |
|||
#elif SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13) |
|||
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt." |
|||
#elif PIN_EXISTS(X_MAX) && X_MAX_PIN == SPINDLE_LASER_PWM_PIN |
|||
#error "SPINDLE_LASER_PWM pin is in use by X_MAX endstop." |
|||
#elif PIN_EXISTS(X_MIN) && X_MIN_PIN == SPINDLE_LASER_PWM_PIN |
|||
#error "SPINDLE_LASER_PWM pin is in use by X_MIN endstop." |
|||
#elif PIN_EXISTS(Z_STEP) && Z_STEP_PIN == SPINDLE_LASER_PWM_PIN |
|||
#error "SPINDLE_LASER_PWM pin in use by Z_STEP." |
|||
#elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) |
|||
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." |
|||
#elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN." |
|||
#elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN_PIN." |
|||
#elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN." |
|||
#elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN." |
|||
#elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN." |
|||
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_XY) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_XY_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_XY." |
|||
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_Z_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_Z." |
|||
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_E) && SPINDLE_LASER_PWM_PIN == MOTOR_CURRENT_PWM_E_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by MOTOR_CURRENT_PWM_E." |
|||
#endif |
|||
#endif |
|||
#endif // SPINDLE_LASER_ENABLE
|
@ -0,0 +1,397 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* PWM print routines for Atmel 8 bit AVR CPUs |
|||
*/ |
|||
|
|||
|
|||
#define AVR_ATmega2560_FAMILY_PLUS_70 (MOTHERBOARD == BOARD_BQ_ZUM_MEGA_3D \ |
|||
|| MOTHERBOARD == BOARD_MIGHTYBOARD_REVE \ |
|||
|| MOTHERBOARD == BOARD_MINIRAMBO \ |
|||
|| MOTHERBOARD == BOARD_SCOOVO_X9H) |
|||
|
|||
#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 digitalPinToTimer_DEBUG(p) digitalPinToTimer(p) |
|||
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p) |
|||
#define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p) |
|||
#define GET_PINMODE(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin)) |
|||
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
|
|||
#include "pinsDebug_plus_70.h" |
|||
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer_plus_70(p) |
|||
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask_plus_70(p) |
|||
#define digitalPinToPort_DEBUG(p) digitalPinToPort_plus_70(p) |
|||
bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); } |
|||
|
|||
#else |
|||
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p) |
|||
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p) |
|||
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p) |
|||
bool GET_PINMODE(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask_DEBUG(pin); } |
|||
#define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin) |
|||
#endif |
|||
|
|||
#define VALID_PIN(pin)) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0) |
|||
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) |
|||
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7))) |
|||
#define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin) |
|||
|
|||
void PRINT_ARRAY_NAME(uint8_t x) { |
|||
char *name_mem_pointer = (char*)pgm_read_word(&pin_array[x].name); |
|||
for (uint8_t y = 0; y < MAX_NAME_LENGTH; y++) { |
|||
char temp_char = pgm_read_byte(name_mem_pointer + y); |
|||
if (temp_char != 0) |
|||
MYSERIAL.write(temp_char); |
|||
else { |
|||
for (uint8_t i = 0; i < MAX_NAME_LENGTH - y; i++) MYSERIAL.write(' '); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
#define GET_ARRAY_IS_DIGITAL(x) pgm_read_byte(&pin_array[x].is_digital) |
|||
|
|||
|
|||
#if defined(__AVR_ATmega1284P__) // 1284 IDE extensions set this to the number of
|
|||
#undef NUM_DIGITAL_PINS // digital only pins while all other CPUs have it
|
|||
#define NUM_DIGITAL_PINS 32 // set to digital only + digital/analog
|
|||
#endif |
|||
|
|||
#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))) { \ |
|||
PWM_PRINT(OCR##N##Z); \ |
|||
return true; \ |
|||
} else return false |
|||
|
|||
|
|||
|
|||
/**
|
|||
* Print a pin's PWM status. |
|||
* Return true if it's currently a PWM pin. |
|||
*/ |
|||
static bool pwm_status(uint8_t pin) { |
|||
char buffer[20]; // for the sprintf statements
|
|||
|
|||
switch (digitalPinToTimer_DEBUG(pin)) { |
|||
|
|||
#if defined(TCCR0A) && defined(COM0A1) |
|||
#ifdef TIMER0A |
|||
#if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
|||
PWM_CASE(0, A); |
|||
#endif |
|||
#endif |
|||
PWM_CASE(0, B); |
|||
#endif |
|||
|
|||
#if defined(TCCR1A) && defined(COM1A1) |
|||
PWM_CASE(1, A); |
|||
PWM_CASE(1, B); |
|||
#if defined(COM1C1) && defined(TIMER1C) |
|||
PWM_CASE(1, C); |
|||
#endif |
|||
#endif |
|||
|
|||
#if defined(TCCR2A) && defined(COM2A1) |
|||
PWM_CASE(2, A); |
|||
PWM_CASE(2, B); |
|||
#endif |
|||
|
|||
#if defined(TCCR3A) && defined(COM3A1) |
|||
PWM_CASE(3, A); |
|||
PWM_CASE(3, B); |
|||
#ifdef COM3C1 |
|||
PWM_CASE(3, C); |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef TCCR4A |
|||
PWM_CASE(4, A); |
|||
PWM_CASE(4, B); |
|||
PWM_CASE(4, C); |
|||
#endif |
|||
|
|||
#if defined(TCCR5A) && defined(COM5A1) |
|||
PWM_CASE(5, A); |
|||
PWM_CASE(5, B); |
|||
PWM_CASE(5, C); |
|||
#endif |
|||
|
|||
case NOT_ON_TIMER: |
|||
default: |
|||
return false; |
|||
} |
|||
SERIAL_PROTOCOL_SP(2); |
|||
} // pwm_status
|
|||
|
|||
|
|||
const volatile uint8_t* const PWM_other[][3] PROGMEM = { |
|||
{ &TCCR0A, &TCCR0B, &TIMSK0 }, |
|||
{ &TCCR1A, &TCCR1B, &TIMSK1 }, |
|||
#if defined(TCCR2A) && defined(COM2A1) |
|||
{ &TCCR2A, &TCCR2B, &TIMSK2 }, |
|||
#endif |
|||
#if defined(TCCR3A) && defined(COM3A1) |
|||
{ &TCCR3A, &TCCR3B, &TIMSK3 }, |
|||
#endif |
|||
#ifdef TCCR4A |
|||
{ &TCCR4A, &TCCR4B, &TIMSK4 }, |
|||
#endif |
|||
#if defined(TCCR5A) && defined(COM5A1) |
|||
{ &TCCR5A, &TCCR5B, &TIMSK5 }, |
|||
#endif |
|||
}; |
|||
|
|||
|
|||
const volatile uint8_t* const PWM_OCR[][3] PROGMEM = { |
|||
|
|||
#ifdef TIMER0A |
|||
{ &OCR0A, &OCR0B, 0 }, |
|||
#else |
|||
{ 0, &OCR0B, 0 }, |
|||
#endif |
|||
|
|||
#if defined(COM1C1) && defined(TIMER1C) |
|||
{ (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, (const uint8_t*)&OCR1C }, |
|||
#else |
|||
{ (const uint8_t*)&OCR1A, (const uint8_t*)&OCR1B, 0 }, |
|||
#endif |
|||
|
|||
#if defined(TCCR2A) && defined(COM2A1) |
|||
{ &OCR2A, &OCR2B, 0 }, |
|||
#endif |
|||
|
|||
#if defined(TCCR3A) && defined(COM3A1) |
|||
#ifdef COM3C1 |
|||
{ (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, (const uint8_t*)&OCR3C }, |
|||
#else |
|||
{ (const uint8_t*)&OCR3A, (const uint8_t*)&OCR3B, 0 }, |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef TCCR4A |
|||
{ (const uint8_t*)&OCR4A, (const uint8_t*)&OCR4B, (const uint8_t*)&OCR4C }, |
|||
#endif |
|||
|
|||
#if defined(TCCR5A) && defined(COM5A1) |
|||
{ (const uint8_t*)&OCR5A, (const uint8_t*)&OCR5B, (const uint8_t*)&OCR5C }, |
|||
#endif |
|||
}; |
|||
|
|||
|
|||
#define TCCR_A(T) pgm_read_word(&PWM_other[T][0]) |
|||
#define TCCR_B(T) pgm_read_word(&PWM_other[T][1]) |
|||
#define TIMSK(T) pgm_read_word(&PWM_other[T][2]) |
|||
#define CS_0 0 |
|||
#define CS_1 1 |
|||
#define CS_2 2 |
|||
#define WGM_0 0 |
|||
#define WGM_1 1 |
|||
#define WGM_2 3 |
|||
#define WGM_3 4 |
|||
#define TOIE 0 |
|||
|
|||
#define OCR_VAL(T, L) pgm_read_word(&PWM_OCR[T][L]) |
|||
|
|||
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) { |
|||
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N); |
|||
SERIAL_PROTOCOLPGM(" COM"); |
|||
SERIAL_PROTOCOLCHAR(N + '0'); |
|||
switch (Z) { |
|||
case 'A': |
|||
SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6)); |
|||
break; |
|||
case 'B': |
|||
SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4)); |
|||
break; |
|||
case 'C': |
|||
SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2)); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
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
|
|||
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); |
|||
|
|||
SERIAL_PROTOCOLPGM(" TIMER"); |
|||
SERIAL_PROTOCOLCHAR(T + '0'); |
|||
SERIAL_PROTOCOLCHAR(L); |
|||
SERIAL_PROTOCOL_SP(3); |
|||
|
|||
if (N == 3) { |
|||
const uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A'); |
|||
PWM_PRINT(*OCRVAL8); |
|||
} |
|||
else { |
|||
const uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A'); |
|||
PWM_PRINT(*OCRVAL16); |
|||
} |
|||
SERIAL_PROTOCOLPAIR(" WGM: ", WGM); |
|||
com_print(T,L); |
|||
SERIAL_PROTOCOLPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) )); |
|||
|
|||
SERIAL_PROTOCOLPGM(" TCCR"); |
|||
SERIAL_PROTOCOLCHAR(T + '0'); |
|||
SERIAL_PROTOCOLPAIR("A: ", *TCCRA); |
|||
|
|||
SERIAL_PROTOCOLPGM(" TCCR"); |
|||
SERIAL_PROTOCOLCHAR(T + '0'); |
|||
SERIAL_PROTOCOLPAIR("B: ", *TCCRB); |
|||
|
|||
const uint8_t *TMSK = (uint8_t*)TIMSK(T); |
|||
SERIAL_PROTOCOLPGM(" TIMSK"); |
|||
SERIAL_PROTOCOLCHAR(T + '0'); |
|||
SERIAL_PROTOCOLPAIR(": ", *TMSK); |
|||
|
|||
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(); |
|||
if (TEST(*TMSK, TOIE)) err_prob_interrupt(); |
|||
} |
|||
|
|||
static void pwm_details(uint8_t pin) { |
|||
switch (digitalPinToTimer_DEBUG(pin)) { |
|||
|
|||
#if defined(TCCR0A) && defined(COM0A1) |
|||
#ifdef TIMER0A |
|||
#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 |
|||
|
|||
#if defined(TCCR1A) && defined(COM1A1) |
|||
case TIMER1A: timer_prefix(1, 'A', 4); break; |
|||
case TIMER1B: timer_prefix(1, 'B', 4); break; |
|||
#if defined(COM1C1) && defined(TIMER1C) |
|||
case TIMER1C: timer_prefix(1, 'C', 4); break; |
|||
#endif |
|||
#endif |
|||
|
|||
#if defined(TCCR2A) && defined(COM2A1) |
|||
case TIMER2A: timer_prefix(2, 'A', 3); break; |
|||
case TIMER2B: timer_prefix(2, 'B', 3); break; |
|||
#endif |
|||
|
|||
#if defined(TCCR3A) && defined(COM3A1) |
|||
case TIMER3A: timer_prefix(3, 'A', 4); break; |
|||
case TIMER3B: timer_prefix(3, 'B', 4); break; |
|||
#ifdef COM3C1 |
|||
case TIMER3C: timer_prefix(3, 'C', 4); break; |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef TCCR4A |
|||
case TIMER4A: timer_prefix(4, 'A', 4); break; |
|||
case TIMER4B: timer_prefix(4, 'B', 4); break; |
|||
case TIMER4C: timer_prefix(4, 'C', 4); break; |
|||
#endif |
|||
|
|||
#if defined(TCCR5A) && defined(COM5A1) |
|||
case TIMER5A: timer_prefix(5, 'A', 4); break; |
|||
case TIMER5B: timer_prefix(5, 'B', 4); break; |
|||
case TIMER5C: timer_prefix(5, 'C', 4); break; |
|||
#endif |
|||
|
|||
case NOT_ON_TIMER: break; |
|||
|
|||
} |
|||
SERIAL_PROTOCOLPGM(" "); |
|||
|
|||
// 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_DEBUG(pin) == 'B' - 64 && 0x80 == digitalPinToBitMask_DEBUG(pin)) { |
|||
#if !AVR_AT90USB1286_FAMILY |
|||
SERIAL_PROTOCOLPGM("\n ."); |
|||
SERIAL_PROTOCOL_SP(18); |
|||
SERIAL_PROTOCOLPGM("TIMER1C"); |
|||
print_is_also_tied(); |
|||
timer_prefix(1, 'C', 4); |
|||
#else |
|||
SERIAL_PROTOCOLPGM("\n ."); |
|||
SERIAL_PROTOCOL_SP(18); |
|||
SERIAL_PROTOCOLPGM("TIMER0A"); |
|||
print_is_also_tied(); |
|||
timer_prefix(0, 'A', 3); |
|||
#endif |
|||
} |
|||
#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); |
|||
return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask_DEBUG(pin)) ? HIGH : LOW; |
|||
} |
|||
#endif |
|||
|
|||
#ifndef PRINT_PORT(p) |
|||
void print_port(int8_t pin) { // print port number
|
|||
#ifdef digitalPinToPort_DEBUG |
|||
uint8_t x; |
|||
SERIAL_PROTOCOLPGM(" Port: "); |
|||
#if AVR_AT90USB1286_FAMILY |
|||
x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64; |
|||
#else |
|||
x = digitalPinToPort_DEBUG(pin) + 64; |
|||
#endif |
|||
SERIAL_CHAR(x); |
|||
|
|||
#if AVR_AT90USB1286_FAMILY |
|||
if (pin == 46) |
|||
x = '2'; |
|||
else if (pin == 47) |
|||
x = '3'; |
|||
else { |
|||
uint8_t temp = digitalPinToBitMask_DEBUG(pin); |
|||
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1; |
|||
} |
|||
#else |
|||
uint8_t temp = digitalPinToBitMask_DEBUG(pin); |
|||
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1; |
|||
#endif |
|||
SERIAL_CHAR(x); |
|||
#else |
|||
SERIAL_PROTOCOL_SP(10); |
|||
#endif |
|||
} |
|||
|
|||
#define PRINT_PORT(p) print_port(p) |
|||
#endif |
@ -0,0 +1,29 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* Test Arduino Due specific configuration values for errors at compile-time. |
|||
*/ |
|||
|
|||
/**
|
|||
* Require gcc 4.7 or newer (first included with Arduino 1.6.8) for C++11 features. |
|||
*/ |
@ -0,0 +1,71 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* Test Re-ARM specific configuration values for errors at compile-time. |
|||
*/ |
|||
|
|||
/**
|
|||
* Require gcc 4.7 or newer (first included with Arduino 1.6.8) for C++11 features. |
|||
*/ |
|||
|
|||
#if ENABLED(SPINDLE_LASER_ENABLE) |
|||
#if !PIN_EXISTS(SPINDLE_LASER_ENABLE) |
|||
#error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN." |
|||
#elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR) |
|||
#error "SPINDLE_DIR_PIN not defined." |
|||
#elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM) |
|||
#if !PWM_PIN(SPINDLE_LASER_PWM_PIN) |
|||
#error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin." |
|||
#elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11) |
|||
#error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector" |
|||
#elif SPINDLE_LASER_POWERUP_DELAY < 1 |
|||
#error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0." |
|||
#elif SPINDLE_LASER_POWERDOWN_DELAY < 1 |
|||
#error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0." |
|||
#elif !defined(SPINDLE_LASER_PWM_INVERT) |
|||
#error "SPINDLE_LASER_PWM_INVERT missing." |
|||
#elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX) |
|||
#error "SPINDLE_LASER_PWM equation constant(s) missing." |
|||
#elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN." |
|||
#elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN." |
|||
#elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN_PIN." |
|||
#elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN." |
|||
#elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN." |
|||
#elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN |
|||
#error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN." |
|||
#endif |
|||
#endif |
|||
#endif // SPINDLE_LASER_ENABLE
|
@ -0,0 +1,37 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
#ifndef HAL_SANITYCHECK_H |
|||
|
|||
#ifdef ARDUINO_ARCH_AVR |
|||
#include "HAL_AVR/SanityCheck_AVR_8_bit.h" |
|||
#elif defined(ARDUINO_ARCH_SAM) |
|||
#include "HAL_DUE/SanityCheck_Due.h" |
|||
#elif IS_32BIT_TEENSY |
|||
#include "HAL_TEENSY35_36/SanityCheck_Teensy_35_36.h" |
|||
#elif defined(TARGET_LPC1768) |
|||
#include "HAL_LPC1768/SanityCheck_Re_ARM.h" |
|||
#else |
|||
#error Unsupported Platform! |
|||
#endif |
|||
|
|||
#endif |
@ -0,0 +1,29 @@ |
|||
/**
|
|||
* Marlin 3D Printer Firmware |
|||
* Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|||
* |
|||
* Based on Sprinter and grbl. |
|||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
/**
|
|||
* Test TEENSY35_36 specific configuration values for errors at compile-time. |
|||
*/ |
|||
|
|||
/**
|
|||
* Require gcc 4.7 or newer (first included with Arduino 1.6.8) for C++11 features. |
|||
*/ |
Loading…
Reference in new issue