teemuatlut
8 years ago
committed by
Scott Lahteine
18 changed files with 1532 additions and 4 deletions
@ -0,0 +1,130 @@ |
|||||
|
/****************************************************************************************
|
||||
|
* Teensy 3.5 (MK64FX512) and Teensy 3.6 (MK66FX1M0) Breadboard pin assignments |
||||
|
* Requires the Teensyduino software with Teensy 3.5 or Teensy 3.6 selected in Arduino IDE! |
||||
|
* http://www.pjrc.com/teensy/teensyduino.html
|
||||
|
* |
||||
|
****************************************************************************************/ |
||||
|
#if MOTHERBOARD == 841 // BOARD_TEENSY35_36
|
||||
|
#define KNOWN_BOARD 1 |
||||
|
#define AT90USB 1286 // Disable MarlinSerial etc.
|
||||
|
|
||||
|
#if !IS_32BIT_TEENSY |
||||
|
#error Oops! Make sure you have 'Teensy 3.5' or 'Teensy 3.6' selected from the 'Tools -> Boards' menu. |
||||
|
#endif |
||||
|
|
||||
|
#if IS_TEENSY35 |
||||
|
#define BOARD_NAME "Teensy3.5" |
||||
|
#elif IS_TEENSY36 |
||||
|
#define BOARD_NAME "Teensy3.6" |
||||
|
#endif |
||||
|
|
||||
|
#define LARGE_FLASH true |
||||
|
#define USBCON //1286 // Disable MarlinSerial etc.
|
||||
|
|
||||
|
/*
|
||||
|
teemuatlut plan for Teensy3.5 and Teensy3.6: |
||||
|
|
||||
|
USB |
||||
|
GND |-----#####-----| VIN 5V |
||||
|
X_STEP_PIN MOSI1 RX1 0 | ##### | Analog GND |
||||
|
X_DIR_PIN MISO1 TX1 1 | | 3.3V |
||||
|
Y_STEP_PIN PWM 2 | *NC AREF* | 23 A9 PWM |
||||
|
Y_DIR_PIN SCL2 CAN0TX PWM 3 | *A26 A10* | 22 A8 PWM |
||||
|
Z_STEP_PIN SDA2 CAN0RX PWM 4 | *A25 A11* | 21 A7 PWM CS0 MOSI1 RX1 |
||||
|
Z_DIR_PIN MISO1 TX1 PWM 5 | *GND * * 57 | 20 A6 PWM CS0 SCK1 FILWIDTH_PIN |
||||
|
X_ENABLE_PIN PWM 6 | *GND * * 56 | 19 A5 SCL0 E0_STEP_PIN |
||||
|
Y_ENABLE_PIN SCL0 MOSI0 RX3 PWM 7 | * * 55 | 18 A4 SDA0 E0_DIR_PIN |
||||
|
Z_ENABLE_PIN SDA0 MISO0 TX3 PWM 8 | * * 54 | 17 A3 SDA0 E0_ENABLE_PIN |
||||
|
CS0 RX2 PWM 9 | | 16 A2 SCL0 TEMP_0_PIN |
||||
|
CS0 TX2 PWM 10 | | 15 A1 CS0 TEMP_BED_PIN |
||||
|
X_STOP_PIN MOSI0 11 | | 14 A0 PWM CS0 TEMP_1_PIN |
||||
|
Y_STOP_PIN MISO0 12 | | 13 LED SCK0 LED_PIN |
||||
|
3.3V | | GND |
||||
|
Z_STOP_PIN 24 | 40 * * 53 | A22 DAC1 |
||||
|
AUX2 25 | 41 * * 52 | A21 DAC0 |
||||
|
AUX2 FAN_PIN SCL2 TX1 26 | 42 * * 51 | 39 A20 MISO0 SDSS |
||||
|
AUX2 Z-PROBE PWR SCK0 RX1 27 | * * * * * | 38 A19 PWM SDA1 |
||||
|
AUX2 SOL1_PIN MOSI0 28 | 43 * * 50 | 37 A18 PWM SCL1 |
||||
|
D10 CONTROLLERFAN_PIN CAN0TX PWM 29 | 44 * * 49 | 36 A17 PWM |
||||
|
D9 HEATER_0_PIN CAN0RX PWM 30 | 45 * * 48 | 35 A16 PWM E1_ENABLE_PIN |
||||
|
D8 HEATER_BED_PIN CS1 RX4 A12 31 | 46 * * 47 | 34 A15 PWM SDA0 RX5 E1_DIR_PIN |
||||
|
SCK1 TX4 A13 32 |__GND_*_*_3.3V_| 33 A14 PWM SCL0 TX5 E1_STEP_PIN |
||||
|
|
||||
|
Interior pins: |
||||
|
LCD_PINS_RS 40 * * 53 SCK2 |
||||
|
LCD_PINS_ENABLE 41 * * 52 MOSI2 |
||||
|
LCD_PINS_D4 42 * * 51 MISO2 |
||||
|
LCD_PINS_D5 CS2 43 * * 50 A24 |
||||
|
LCD_PINS_D6 MOSI2 44 * * 49 A23 |
||||
|
LCD_PINS_D7 MISO2 45 * * 48 TX6 SDA0 BTN_ENC |
||||
|
BTN_EN1 SCK2 46 * * 47 RX6 SCL0 BTN_EN2 |
||||
|
GND * * 3.3V |
||||
|
|
||||
|
*/ |
||||
|
|
||||
|
#define X_STEP_PIN 22 |
||||
|
#define X_DIR_PIN 21 |
||||
|
#define X_ENABLE_PIN 39 |
||||
|
|
||||
|
#define Y_STEP_PIN 19 |
||||
|
#define Y_DIR_PIN 18 |
||||
|
#define Y_ENABLE_PIN 20 |
||||
|
|
||||
|
#define Z_STEP_PIN 38 |
||||
|
#define Z_DIR_PIN 37 |
||||
|
#define Z_ENABLE_PIN 17 |
||||
|
|
||||
|
#define E0_STEP_PIN 31 |
||||
|
#define E0_DIR_PIN 30 |
||||
|
#define E0_ENABLE_PIN 32 |
||||
|
|
||||
|
#define E1_STEP_PIN 33 |
||||
|
#define E1_DIR_PIN 34 |
||||
|
#define E1_ENABLE_PIN 35 |
||||
|
|
||||
|
#define HEATER_0_PIN 30 |
||||
|
#define HEATER_1_PIN 36 |
||||
|
#define HEATER_2_PIN -1 |
||||
|
#define HEATER_BED_PIN 31 |
||||
|
#define FAN_PIN 2 |
||||
|
|
||||
|
#define X_STOP_PIN 24 |
||||
|
#define Y_STOP_PIN 26 |
||||
|
#define Z_STOP_PIN 28 |
||||
|
|
||||
|
#define TEMP_0_PIN 2 // Extruder / Analog pin numbering: 2 => A2
|
||||
|
#define TEMP_BED_PIN 1 // Bed / Analog pin numbering
|
||||
|
#define TEMP_1_PIN 0 |
||||
|
#define TEMP_2_PIN -1 |
||||
|
|
||||
|
#define SDPOWER -1 |
||||
|
#define SD_DETECT_PIN -1 |
||||
|
#define SDSS 39 // 8
|
||||
|
#define LED_PIN 13 |
||||
|
#define PS_ON_PIN 1 |
||||
|
#define KILL_PIN -1 |
||||
|
#define ALARM_PIN -1 |
||||
|
|
||||
|
#define FILWIDTH_PIN 6 |
||||
|
#define SOL1_PIN 28 |
||||
|
|
||||
|
#ifndef SDSUPPORT |
||||
|
// these pins are defined in the SD library if building with SD support
|
||||
|
#define SCK_PIN 13 |
||||
|
#define MISO_PIN 12 |
||||
|
#define MOSI_PIN 11 |
||||
|
#endif |
||||
|
|
||||
|
#ifdef ULTRA_LCD |
||||
|
#define LCD_PINS_RS 40 |
||||
|
#define LCD_PINS_ENABLE 41 |
||||
|
#define LCD_PINS_D4 42 |
||||
|
#define LCD_PINS_D5 43 |
||||
|
#define LCD_PINS_D6 44 |
||||
|
#define LCD_PINS_D7 45 |
||||
|
#define BTN_EN1 46 |
||||
|
#define BTN_EN2 47 |
||||
|
#define BTN_ENC 48 |
||||
|
#endif |
||||
|
|
||||
|
#endif // MOTHERBOARD == 841 (Teensy3.5 and Teensy3.6)
|
@ -0,0 +1,28 @@ |
|||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
|
||||
|
|
||||
|
#include "HAL_Servo_Teensy.h" |
||||
|
#include "../../../MarlinConfig.h" |
||||
|
|
||||
|
|
||||
|
int8_t libServo::attach(int pin) { |
||||
|
if (this->servoIndex >= MAX_SERVOS) return -1; |
||||
|
return Servo::attach(pin); |
||||
|
} |
||||
|
|
||||
|
int8_t libServo::attach(int pin, int min, int max) { |
||||
|
return Servo::attach(pin, min, max); |
||||
|
} |
||||
|
|
||||
|
void libServo::move(int value) { |
||||
|
if (this->attach(0) >= 0) { |
||||
|
this->write(value); |
||||
|
delay(SERVO_DELAY); |
||||
|
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) |
||||
|
this->detach(); |
||||
|
#endif |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif |
@ -0,0 +1,18 @@ |
|||||
|
#ifndef HAL_Servo_Teensy_h |
||||
|
#define HAL_Servo_Teensy_h |
||||
|
|
||||
|
#include <Servo.h> |
||||
|
|
||||
|
// Inherit and expand on the official library
|
||||
|
class libServo : public Servo { |
||||
|
public: |
||||
|
int8_t attach(int pin); |
||||
|
int8_t attach(int pin, int min, int max); |
||||
|
void move(int value); |
||||
|
private: |
||||
|
uint16_t min_ticks; |
||||
|
uint16_t max_ticks; |
||||
|
uint8_t servoIndex; // index into the channel data for this servo
|
||||
|
}; |
||||
|
|
||||
|
#endif |
@ -0,0 +1,119 @@ |
|||||
|
/* **************************************************************************
|
||||
|
|
||||
|
Marlin 3D Printer Firmware |
||||
|
Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com |
||||
|
|
||||
|
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/>.
|
||||
|
****************************************************************************/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Description: HAL for Teensy35 (MK64FX512) |
||||
|
*/ |
||||
|
|
||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
|
||||
|
#include "../HAL.h" |
||||
|
|
||||
|
#include <Wire.h> |
||||
|
|
||||
|
uint16_t HAL_adc_result; |
||||
|
|
||||
|
|
||||
|
static const uint8_t pin2sc1a[] = { |
||||
|
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13
|
||||
|
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9
|
||||
|
255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only
|
||||
|
14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20
|
||||
|
255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only
|
||||
|
10+128, 11+128, // 49-50 are A23-A24
|
||||
|
255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only
|
||||
|
255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only
|
||||
|
3, 19+128, // 64-65 are A10-A11
|
||||
|
23, 23+128,// 66-67 are A21-A22 (DAC pins)
|
||||
|
1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5)
|
||||
|
26, // 70 is Temperature Sensor
|
||||
|
18+128 // 71 is Vref
|
||||
|
}; |
||||
|
|
||||
|
/*
|
||||
|
// disable interrupts
|
||||
|
void cli(void) |
||||
|
{ |
||||
|
noInterrupts(); |
||||
|
} |
||||
|
|
||||
|
// enable interrupts
|
||||
|
void sei(void) |
||||
|
{ |
||||
|
interrupts(); |
||||
|
} |
||||
|
*/ |
||||
|
void HAL_adc_init() { |
||||
|
analog_init(); |
||||
|
while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
|
||||
|
NVIC_ENABLE_IRQ(IRQ_FTM1); |
||||
|
} |
||||
|
|
||||
|
void HAL_clear_reset_source (void) |
||||
|
{ } |
||||
|
|
||||
|
uint8_t HAL_get_reset_source (void) |
||||
|
{ |
||||
|
switch ( RCM_SRS0 ) |
||||
|
{ |
||||
|
case 128: return RST_POWER_ON; break; |
||||
|
case 64: return RST_EXTERNAL; break; |
||||
|
case 32: return RST_WATCHDOG; break; |
||||
|
// case 8: return RST_LOSS_OF_LOCK; break;
|
||||
|
// case 4: return RST_LOSS_OF_CLOCK; break;
|
||||
|
// case 2: return RST_LOW_VOLTAGE; break;
|
||||
|
default: |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void _delay_ms (int delay_ms) |
||||
|
{ |
||||
|
delay (delay_ms); |
||||
|
} |
||||
|
|
||||
|
extern "C" { |
||||
|
extern char __bss_end; |
||||
|
extern char __heap_start; |
||||
|
extern void* __brkval; |
||||
|
|
||||
|
int freeMemory() { |
||||
|
int free_memory; |
||||
|
if ((int)__brkval == 0) |
||||
|
free_memory = ((int)&free_memory) - ((int)&__bss_end); |
||||
|
else |
||||
|
free_memory = ((int)&free_memory) - ((int)__brkval); |
||||
|
return free_memory; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HAL_adc_start_conversion (uint8_t adc_pin) |
||||
|
{ |
||||
|
ADC0_SC1A = pin2sc1a[adc_pin]; |
||||
|
} |
||||
|
|
||||
|
uint16_t HAL_adc_get_result(void) |
||||
|
{ |
||||
|
return ADC0_RA; |
||||
|
} |
||||
|
|
||||
|
#endif // __MK64FX512__ || __MK66FX1M0__
|
||||
|
|
@ -0,0 +1,149 @@ |
|||||
|
/* **************************************************************************
|
||||
|
|
||||
|
Marlin 3D Printer Firmware |
||||
|
Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com |
||||
|
Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com |
||||
|
|
||||
|
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/>.
|
||||
|
****************************************************************************/ |
||||
|
|
||||
|
/**
|
||||
|
* Description: HAL for Teensy 3.5 and Teensy 3.6 |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#ifndef _HAL_TEENSY_H |
||||
|
#define _HAL_TEENSY_H |
||||
|
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
// Includes
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
#include "Arduino.h" |
||||
|
|
||||
|
#include "fastio_Teensy.h" |
||||
|
#include "watchdog_Teensy.h" |
||||
|
|
||||
|
#include "HAL_timers_Teensy.h" |
||||
|
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
// Defines
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
|
||||
|
#define MOTHERBOARD BOARD_TEENSY35_36 |
||||
|
|
||||
|
#define IS_32BIT_TEENSY (defined(__MK64FX512__) || defined(__MK66FX1M0__)) |
||||
|
#define IS_TEENSY35 defined(__MK64FX512__) |
||||
|
#define IS_TEENSY36 defined(__MK66FX1M0__) |
||||
|
|
||||
|
#if SERIAL_PORT == -1 |
||||
|
#define MYSERIAL SerialUSB |
||||
|
#elif SERIAL_PORT == 0 |
||||
|
#define MYSERIAL Serial |
||||
|
#elif SERIAL_PORT == 1 |
||||
|
#define MYSERIAL Serial1 |
||||
|
#elif SERIAL_PORT == 2 |
||||
|
#define MYSERIAL Serial2 |
||||
|
#elif SERIAL_PORT == 3 |
||||
|
#define MYSERIAL Serial3 |
||||
|
#endif |
||||
|
|
||||
|
#define HAL_SERVO_LIB libServo |
||||
|
|
||||
|
//#define _BV(bit) (1 << (bit))
|
||||
|
|
||||
|
#ifndef analogInputToDigitalPin |
||||
|
#define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) |
||||
|
#endif |
||||
|
|
||||
|
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); |
||||
|
#define CRITICAL_SECTION_END SREG = _sreg; |
||||
|
|
||||
|
|
||||
|
// On AVR this is in math.h?
|
||||
|
#define square(x) ((x)*(x)) |
||||
|
|
||||
|
#ifndef strncpy_P |
||||
|
#define strncpy_P(dest, src, num) strncpy((dest), (src), (num)) |
||||
|
#endif |
||||
|
|
||||
|
// Fix bug in pgm_read_ptr
|
||||
|
#undef pgm_read_ptr |
||||
|
#define pgm_read_ptr(addr) (*(addr)) |
||||
|
#undef pgm_read_word |
||||
|
#define pgm_read_word(addr) (*(addr)) |
||||
|
|
||||
|
#define RST_POWER_ON 1 |
||||
|
#define RST_EXTERNAL 2 |
||||
|
#define RST_BROWN_OUT 4 |
||||
|
#define RST_WATCHDOG 8 |
||||
|
#define RST_JTAG 16 |
||||
|
#define RST_SOFTWARE 32 |
||||
|
#define RST_BACKUP 64 |
||||
|
|
||||
|
/** clear reset reason */ |
||||
|
void HAL_clear_reset_source (void); |
||||
|
|
||||
|
/** reset reason */ |
||||
|
uint8_t HAL_get_reset_source (void); |
||||
|
|
||||
|
void _delay_ms(int delay); |
||||
|
|
||||
|
extern "C" { |
||||
|
int freeMemory(void); |
||||
|
} |
||||
|
|
||||
|
// SPI: Extended functions which take a channel number (hardware SPI only)
|
||||
|
/** Write single byte to specified SPI channel */ |
||||
|
void spiSend(uint32_t chan, byte b); |
||||
|
/** Write buffer to specified SPI channel */ |
||||
|
void spiSend(uint32_t chan, const uint8_t* buf, size_t n); |
||||
|
/** Read single byte from specified SPI channel */ |
||||
|
uint8_t spiRec(uint32_t chan); |
||||
|
|
||||
|
// ADC
|
||||
|
|
||||
|
void HAL_adc_init(); |
||||
|
|
||||
|
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) |
||||
|
#define HAL_READ_ADC HAL_adc_get_result() |
||||
|
|
||||
|
#define HAL_ANALOG_SELECT(pin) NOOP; |
||||
|
|
||||
|
void HAL_adc_start_conversion (uint8_t adc_pin); |
||||
|
|
||||
|
uint16_t HAL_adc_get_result(void); |
||||
|
|
||||
|
/*
|
||||
|
uint16_t HAL_getAdcReading(uint8_t chan); |
||||
|
|
||||
|
void HAL_startAdcConversion(uint8_t chan); |
||||
|
uint8_t HAL_pinToAdcChannel(int pin); |
||||
|
|
||||
|
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false); |
||||
|
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
||||
|
|
||||
|
void HAL_enable_AdcFreerun(void); |
||||
|
//void HAL_disable_AdcFreerun(uint8_t chan);
|
||||
|
*/ |
||||
|
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
//
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
|
||||
|
#endif // _HAL_TEENSY_H
|
||||
|
|
@ -0,0 +1,107 @@ |
|||||
|
/**
|
||||
|
* 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_PINSDEBUG_TEENSY_H |
||||
|
|
||||
|
#define FTM0_CH0_PIN 22 |
||||
|
#define FTM0_CH1_PIN 23 |
||||
|
#define FTM0_CH2_PIN 9 |
||||
|
#define FTM0_CH3_PIN 10 |
||||
|
#define FTM0_CH4_PIN 6 |
||||
|
#define FTM0_CH5_PIN 20 |
||||
|
#define FTM0_CH6_PIN 21 |
||||
|
#define FTM0_CH7_PIN 5 |
||||
|
#define FTM1_CH0_PIN 3 |
||||
|
#define FTM1_CH1_PIN 4 |
||||
|
#define FTM2_CH0_PIN 29 |
||||
|
#define FTM2_CH1_PIN 30 |
||||
|
#define FTM3_CH0_PIN 2 |
||||
|
#define FTM3_CH1_PIN 14 |
||||
|
#define FTM3_CH2_PIN 7 |
||||
|
#define FTM3_CH3_PIN 8 |
||||
|
#define FTM3_CH4_PIN 35 |
||||
|
#define FTM3_CH5_PIN 36 |
||||
|
#define FTM3_CH6_PIN 37 |
||||
|
#define FTM3_CH7_PIN 38 |
||||
|
#if defined(__MK66FX1M0__) // Teensy3.6
|
||||
|
#define TPM1_CH0_PIN 16 |
||||
|
#define TPM1_CH1_PIN 17 |
||||
|
#endif |
||||
|
|
||||
|
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(9)) || ((P) >= analogInputToDigitalPin(12) && (P) <= analogInputToDigitalPin(20)) |
||||
|
|
||||
|
void HAL_print_analog_pin(char buffer[], int8_t pin) { |
||||
|
if (pin <= 23) sprintf(buffer, "(A%2d) ", int(pin - 14)); |
||||
|
else if (pin <= 39) sprintf(buffer, "(A%2d) ", int(pin - 19)); |
||||
|
} |
||||
|
|
||||
|
void HAL_analog_pin_state(char buffer[], int8_t pin) { |
||||
|
if (pin <= 23) sprintf(buffer, "Analog in =% 5d", analogRead(pin - 14)); |
||||
|
else if (pin <= 39) sprintf(buffer, "Analog in =% 5d", analogRead(pin - 19)); |
||||
|
} |
||||
|
|
||||
|
#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", 22); SERIAL_ECHO(buffer); }while(0) |
||||
|
#define FTM_CASE(N,Z) \ |
||||
|
case FTM##N##_CH##Z##_PIN: \ |
||||
|
if (FTM##N##_C##Z##V) { \ |
||||
|
PWM_PRINT(FTM##N##_C##Z##V); \ |
||||
|
return true; \ |
||||
|
} else return false |
||||
|
|
||||
|
/**
|
||||
|
* Print a pin's PWM status. |
||||
|
* Return true if it's currently a PWM pin. |
||||
|
*/ |
||||
|
bool HAL_pwm_status(int8_t pin) { |
||||
|
char buffer[20]; // for the sprintf statements
|
||||
|
switch(pin) { |
||||
|
FTM_CASE(0,0); |
||||
|
FTM_CASE(0,1); |
||||
|
FTM_CASE(0,2); |
||||
|
FTM_CASE(0,3); |
||||
|
FTM_CASE(0,4); |
||||
|
FTM_CASE(0,5); |
||||
|
FTM_CASE(0,6); |
||||
|
FTM_CASE(0,7); |
||||
|
FTM_CASE(1,0); |
||||
|
FTM_CASE(1,1); |
||||
|
FTM_CASE(2,0); |
||||
|
FTM_CASE(2,1); |
||||
|
FTM_CASE(3,0); |
||||
|
FTM_CASE(3,1); |
||||
|
FTM_CASE(3,2); |
||||
|
FTM_CASE(3,3); |
||||
|
FTM_CASE(3,4); |
||||
|
FTM_CASE(3,5); |
||||
|
FTM_CASE(3,6); |
||||
|
FTM_CASE(3,7); |
||||
|
|
||||
|
case NOT_ON_TIMER: |
||||
|
default: |
||||
|
return false; |
||||
|
} |
||||
|
SERIAL_PROTOCOLPGM(" "); |
||||
|
} |
||||
|
|
||||
|
static void HAL_pwm_details(uint8_t pin) { /* TODO */ } |
||||
|
|
||||
|
#endif |
@ -0,0 +1,104 @@ |
|||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
|
||||
|
#include "../HAL.h" |
||||
|
#include <SPI.h> |
||||
|
#include <pins_arduino.h> |
||||
|
#include "spi_pins.h" |
||||
|
#include "../../../macros.h" |
||||
|
|
||||
|
static SPISettings spiConfig; |
||||
|
|
||||
|
// Standard SPI functions
|
||||
|
/** Initialise SPI bus */ |
||||
|
void spiBegin(void) { |
||||
|
#ifndef SS_PIN |
||||
|
#error SS_PIN not defined! |
||||
|
#endif |
||||
|
SET_OUTPUT(SS_PIN); |
||||
|
WRITE(SS_PIN, HIGH); |
||||
|
SET_OUTPUT(SCK_PIN); |
||||
|
SET_INPUT(MISO_PIN); |
||||
|
SET_OUTPUT(MOSI_PIN); |
||||
|
|
||||
|
//#if DISABLED(SOFTWARE_SPI)
|
||||
|
#if false |
||||
|
// set SS high - may be chip select for another SPI device
|
||||
|
#if SET_SPI_SS_HIGH |
||||
|
WRITE(SS_PIN, HIGH); |
||||
|
#endif // SET_SPI_SS_HIGH
|
||||
|
// set a default rate
|
||||
|
spiInit(SPI_HALF_SPEED); // 1
|
||||
|
#endif // SOFTWARE_SPI
|
||||
|
} |
||||
|
|
||||
|
/** Configure SPI for specified SPI speed */ |
||||
|
void spiInit(uint8_t spiRate) { |
||||
|
// Use datarates Marlin uses
|
||||
|
uint32_t clock; |
||||
|
switch (spiRate) { |
||||
|
case SPI_FULL_SPEED: clock = 10000000; break; |
||||
|
case SPI_HALF_SPEED: clock = 5000000; break; |
||||
|
case SPI_QUARTER_SPEED: clock = 2500000; break; |
||||
|
case SPI_EIGHTH_SPEED: clock = 1250000; break; |
||||
|
case SPI_SPEED_5: clock = 625000; break; |
||||
|
case SPI_SPEED_6: clock = 312500; break; |
||||
|
default: |
||||
|
clock = 4000000; // Default from the SPI libarary
|
||||
|
} |
||||
|
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0); |
||||
|
SPI.begin(); |
||||
|
} |
||||
|
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
/** SPI receive a byte */ |
||||
|
uint8_t spiRec(void) { |
||||
|
SPI.beginTransaction(spiConfig); |
||||
|
uint8_t returnByte = SPI.transfer(0xFF); |
||||
|
SPI.endTransaction(); |
||||
|
return returnByte; |
||||
|
// SPDR = 0XFF;
|
||||
|
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||
|
// return SPDR;
|
||||
|
} |
||||
|
//------------------------------------------------------------------------------
|
||||
|
/** SPI read data */ |
||||
|
void spiRead(uint8_t* buf, uint16_t nbyte) { |
||||
|
SPI.beginTransaction(spiConfig); |
||||
|
SPI.transfer(buf, nbyte); |
||||
|
SPI.endTransaction(); |
||||
|
//if (nbyte-- == 0) return;
|
||||
|
// SPDR = 0XFF;
|
||||
|
//for (uint16_t i = 0; i < nbyte; i++) {
|
||||
|
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||
|
// buf[i] = SPDR;
|
||||
|
// SPDR = 0XFF;
|
||||
|
//}
|
||||
|
//while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||
|
//buf[nbyte] = SPDR;
|
||||
|
} |
||||
|
//------------------------------------------------------------------------------
|
||||
|
/** SPI send a byte */ |
||||
|
void spiSend(uint8_t b) { |
||||
|
SPI.beginTransaction(spiConfig); |
||||
|
SPI.transfer(b); |
||||
|
SPI.endTransaction(); |
||||
|
// SPDR = b;
|
||||
|
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
|
||||
|
} |
||||
|
//------------------------------------------------------------------------------
|
||||
|
/** SPI send block */ |
||||
|
void spiSendBlock(uint8_t token, const uint8_t* buf) { |
||||
|
SPI.beginTransaction(spiConfig); |
||||
|
SPDR = token; |
||||
|
for (uint16_t i = 0; i < 512; i += 2) { |
||||
|
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } |
||||
|
SPDR = buf[i]; |
||||
|
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } |
||||
|
SPDR = buf[i + 1]; |
||||
|
} |
||||
|
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } |
||||
|
SPI.endTransaction(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif |
@ -0,0 +1,95 @@ |
|||||
|
/* **************************************************************************
|
||||
|
|
||||
|
Marlin 3D Printer Firmware |
||||
|
Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com |
||||
|
|
||||
|
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/>.
|
||||
|
****************************************************************************/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Teensy3.5 __MK64FX512__ |
||||
|
* Teensy3.6 __MK66FX1M0__ |
||||
|
*/ |
||||
|
|
||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
|
||||
|
#include "../HAL.h" |
||||
|
#include "HAL_timers_Teensy.h" |
||||
|
|
||||
|
|
||||
|
void HAL_timer_start (uint8_t timer_num, uint32_t frequency) { |
||||
|
switch (timer_num) { |
||||
|
case 0: |
||||
|
FTM0_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; |
||||
|
FTM0_SC = 0x00; // Set this to zero before changing the modulus
|
||||
|
FTM0_CNT = 0x0000; // Reset the count to zero
|
||||
|
FTM0_MOD = 0xFFFF; // max modulus = 65535
|
||||
|
FTM0_C0V = FTM0_TIMER_RATE / frequency; // Initial FTM Channel 0 compare value
|
||||
|
FTM0_SC = (FTM_SC_CLKS(0b1)&FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM0_TIMER_PRESCALE_BITS)&FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 8
|
||||
|
FTM0_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA; |
||||
|
break; |
||||
|
case 1: |
||||
|
FTM1_MODE = FTM_MODE_WPDIS | FTM_MODE_FTMEN; // Disable write protection, Enable FTM1
|
||||
|
FTM1_SC = 0x00; // Set this to zero before changing the modulus
|
||||
|
FTM1_CNT = 0x0000; // Reset the count to zero
|
||||
|
FTM1_MOD = 0xFFFF; // max modulus = 65535
|
||||
|
FTM1_C0V = FTM1_TIMER_RATE / frequency; // Initial FTM Channel 0 compare value 65535
|
||||
|
FTM1_SC = (FTM_SC_CLKS(0b1)&FTM_SC_CLKS_MASK) | (FTM_SC_PS(FTM1_TIMER_PRESCALE_BITS)&FTM_SC_PS_MASK); // Bus clock 60MHz divided by prescaler 4
|
||||
|
FTM1_C0SC = FTM_CSC_CHIE | FTM_CSC_MSA | FTM_CSC_ELSA; |
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HAL_timer_enable_interrupt (uint8_t timer_num) |
||||
|
{ |
||||
|
switch(timer_num) { |
||||
|
case 0: NVIC_ENABLE_IRQ(IRQ_FTM0); break; |
||||
|
case 1: NVIC_ENABLE_IRQ(IRQ_FTM1); break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HAL_timer_disable_interrupt (uint8_t timer_num) |
||||
|
{ |
||||
|
switch (timer_num) { |
||||
|
case 0: NVIC_DISABLE_IRQ(IRQ_FTM0); break; |
||||
|
case 1: NVIC_DISABLE_IRQ(IRQ_FTM1); break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HAL_timer_isr_prologue(uint8_t timer_num) { |
||||
|
switch(timer_num) { |
||||
|
case 0: |
||||
|
FTM0_CNT = 0x0000; |
||||
|
FTM0_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
|
FTM0_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
|
break; |
||||
|
case 1: |
||||
|
FTM1_CNT = 0x0000; |
||||
|
FTM1_SC &= ~FTM_SC_TOF; // Clear FTM Overflow flag
|
||||
|
FTM1_C0SC &= ~FTM_CSC_CHF; // Clear FTM Channel Compare flag
|
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endif // Teensy3.5 or Teensy3.6
|
@ -0,0 +1,109 @@ |
|||||
|
/* **************************************************************************
|
||||
|
|
||||
|
Marlin 3D Printer Firmware |
||||
|
Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com |
||||
|
Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com |
||||
|
|
||||
|
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/>.
|
||||
|
****************************************************************************/ |
||||
|
|
||||
|
/**
|
||||
|
* Description: HAL for |
||||
|
* Teensy3.5 (__MK64FX512__) |
||||
|
* Teensy3.6 (__MK66FX1M0__) |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#ifndef _HAL_TIMERS_TEENSY_H |
||||
|
#define _HAL_TIMERS_TEENSY_H |
||||
|
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
// Includes
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
// Defines
|
||||
|
// --------------------------------------------------------------------------
|
||||
|
|
||||
|
#define FORCE_INLINE __attribute__((always_inline)) inline |
||||
|
|
||||
|
#define HAL_TIMER_TYPE uint32_t |
||||
|
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF |
||||
|
|
||||
|
#define STEP_TIMER_NUM 0 |
||||
|
#define TEMP_TIMER_NUM 1 |
||||
|
|
||||
|
#define FTM0_TIMER_PRESCALE 8 |
||||
|
#define FTM1_TIMER_PRESCALE 4 |
||||
|
#define FTM0_TIMER_PRESCALE_BITS 0b011 |
||||
|
#define FTM1_TIMER_PRESCALE_BITS 0b010 |
||||
|
|
||||
|
#define FTM0_TIMER_RATE F_BUS/FTM0_TIMER_PRESCALE // 60MHz / 8 = 7500kHz
|
||||
|
#define FTM1_TIMER_RATE F_BUS/FTM1_TIMER_PRESCALE // 60MHz / 4 = 15MHz
|
||||
|
|
||||
|
#define STEPPER_TIMER STEP_TIMER_NUM // Alias?
|
||||
|
#define STEPPER_TIMER_PRESCALE 0 // Not defined anywhere else!
|
||||
|
|
||||
|
#define HAL_TIMER_RATE (FTM0_TIMER_RATE) |
||||
|
#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE |
||||
|
#define HAL_TICKS_PER_US (HAL_STEPPER_TIMER_RATE/1000000) |
||||
|
|
||||
|
#define TEMP_TIMER_FREQUENCY 1000 |
||||
|
|
||||
|
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM) |
||||
|
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt (STEP_TIMER_NUM) |
||||
|
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt (TEMP_TIMER_NUM) |
||||
|
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM) |
||||
|
|
||||
|
#define HAL_STEP_TIMER_ISR extern "C" void ftm0_isr(void) //void TC3_Handler()
|
||||
|
#define HAL_TEMP_TIMER_ISR extern "C" void ftm1_isr(void) //void TC4_Handler()
|
||||
|
|
||||
|
#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0) |
||||
|
|
||||
|
void HAL_timer_start (uint8_t timer_num, uint32_t frequency); |
||||
|
|
||||
|
static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count) { |
||||
|
switch(timer_num) { |
||||
|
case 0: FTM0_C0V = count; break; |
||||
|
case 1: FTM1_C0V = count; break; |
||||
|
default: break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count (uint8_t timer_num) { |
||||
|
switch(timer_num) { |
||||
|
case 0: return FTM0_C0V; |
||||
|
case 1: return FTM1_C0V; |
||||
|
default: return 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static FORCE_INLINE uint32_t HAL_timer_get_current_count(uint8_t timer_num) { |
||||
|
switch(timer_num) { |
||||
|
case 0: return FTM0_CNT; |
||||
|
case 1: return FTM1_CNT; |
||||
|
default: return 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HAL_timer_enable_interrupt (uint8_t timer_num); |
||||
|
void HAL_timer_disable_interrupt (uint8_t timer_num); |
||||
|
|
||||
|
void HAL_timer_isr_prologue(uint8_t timer_num); |
||||
|
|
||||
|
#endif // _HAL_TIMERS_TEENSY_H
|
||||
|
|
@ -0,0 +1,84 @@ |
|||||
|
/**
|
||||
|
* 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/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Endstop Interrupts |
||||
|
* |
||||
|
* Without endstop interrupts the endstop pins must be polled continually in |
||||
|
* the stepper-ISR via endstops.update(), most of the time finding no change. |
||||
|
* With this feature endstops.update() is called only when we know that at |
||||
|
* least one endstop has changed state, saving valuable CPU cycles. |
||||
|
* |
||||
|
* This feature only works when all used endstop pins can generate an 'external interrupt'. |
||||
|
* |
||||
|
* Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'. |
||||
|
* (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino) |
||||
|
*/ |
||||
|
|
||||
|
#ifndef _ENDSTOP_INTERRUPTS_H_ |
||||
|
#define _ENDSTOP_INTERRUPTS_H_ |
||||
|
|
||||
|
/**
|
||||
|
* Endstop interrupts for Due based targets. |
||||
|
* On Due, all pins support external interrupt capability. |
||||
|
*/ |
||||
|
|
||||
|
void setup_endstop_interrupts( void ) { |
||||
|
|
||||
|
#if HAS_X_MAX |
||||
|
attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
|
||||
|
#endif |
||||
|
|
||||
|
#if HAS_X_MIN |
||||
|
attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Y_MAX |
||||
|
attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Y_MIN |
||||
|
attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Z_MAX |
||||
|
attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Z_MIN |
||||
|
attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Z2_MAX |
||||
|
attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Z2_MIN |
||||
|
attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
|
||||
|
#if HAS_Z_MIN_PROBE_PIN |
||||
|
attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE); |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
#endif //_ENDSTOP_INTERRUPTS_H_
|
@ -0,0 +1,120 @@ |
|||||
|
/**
|
||||
|
* 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/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
This code contributed by Triffid_Hunter and modified by Kliment |
||||
|
why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
|
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Description: Fast IO functions for Teensy 3.5 and Teensy 3.6 |
||||
|
*/ |
||||
|
|
||||
|
#ifndef _FASTIO_TEENSY_H |
||||
|
#define _FASTIO_TEENSY_H |
||||
|
|
||||
|
/**
|
||||
|
utility functions |
||||
|
*/ |
||||
|
|
||||
|
#ifndef MASK |
||||
|
#define MASK(PIN) (1 << PIN) |
||||
|
#endif |
||||
|
|
||||
|
#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000) |
||||
|
#define GPIO_BITBAND(reg, bit) (*(uint32_t *)GPIO_BITBAND_ADDR((reg), (bit))) |
||||
|
|
||||
|
/**
|
||||
|
magic I/O routines |
||||
|
now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0); |
||||
|
*/ |
||||
|
|
||||
|
/// Read a pin
|
||||
|
#define _READ(p) ((bool)(CORE_PIN ## p ## _PINREG & CORE_PIN ## p ## _BITMASK)) |
||||
|
|
||||
|
/// Write to a pin
|
||||
|
#define _WRITE(p, v) do { if (v) CORE_PIN ## p ## _PORTSET = CORE_PIN ## p ## _BITMASK; \ |
||||
|
else CORE_PIN ## p ## _PORTCLEAR = CORE_PIN ## p ## _BITMASK; } while (0) |
||||
|
|
||||
|
/// toggle a pin
|
||||
|
#define _TOGGLE(p) (*(&(CORE_PIN ## p ## _PORTCLEAR)+1) = CORE_PIN ## p ## _BITMASK) |
||||
|
|
||||
|
/// set pin as input
|
||||
|
#define _SET_INPUT(p) do { CORE_PIN ## p ## _CONFIG = PORT_PCR_MUX(1); \ |
||||
|
GPIO_BITBAND(CORE_PIN ## p ## _DDRREG , CORE_PIN ## p ## _BIT) = 0; \ |
||||
|
} while (0) |
||||
|
/// set pin as output
|
||||
|
#define _SET_OUTPUT(p) do { CORE_PIN ## p ## _CONFIG = PORT_PCR_MUX(1)|PORT_PCR_SRE|PORT_PCR_DSE; \ |
||||
|
GPIO_BITBAND(CORE_PIN ## p ## _DDRREG , CORE_PIN ## p ## _BIT) = 1; \ |
||||
|
} while (0) |
||||
|
|
||||
|
/// set pin as input with pullup mode
|
||||
|
//#define _PULLUP(IO, v) { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); }
|
||||
|
|
||||
|
/// check if pin is an input
|
||||
|
#define _GET_INPUT(p) ((CORE_PIN ## p ## _DDRREG & CORE_PIN ## p ## _BITMASK) == 0) |
||||
|
/// check if pin is an output
|
||||
|
#define _GET_OUTPUT(p) ((CORE_PIN ## p ## _DDRREG & CORE_PIN ## p ## _BITMASK) == 0) |
||||
|
|
||||
|
/// check if pin is an timer
|
||||
|
//#define _GET_TIMER(IO)
|
||||
|
|
||||
|
// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
|
||||
|
|
||||
|
/// Read a pin wrapper
|
||||
|
#define READ(IO) _READ(IO) |
||||
|
|
||||
|
/// Write to a pin wrapper
|
||||
|
#define WRITE_VAR(IO, v) _WRITE_VAR(IO, v) |
||||
|
#define WRITE(IO, v) _WRITE(IO, v) |
||||
|
|
||||
|
/// toggle a pin wrapper
|
||||
|
#define TOGGLE(IO) _TOGGLE(IO) |
||||
|
|
||||
|
/// set pin as input wrapper
|
||||
|
#define SET_INPUT(IO) _SET_INPUT(IO) |
||||
|
/// set pin as input with pullup wrapper
|
||||
|
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _WRITE(IO, HIGH); }while(0) |
||||
|
/// set pin as output wrapper
|
||||
|
#define SET_OUTPUT(IO) _SET_OUTPUT(IO) |
||||
|
|
||||
|
/// check if pin is an input wrapper
|
||||
|
#define GET_INPUT(IO) _GET_INPUT(IO) |
||||
|
/// check if pin is an output wrapper
|
||||
|
#define GET_OUTPUT(IO) _GET_OUTPUT(IO) |
||||
|
|
||||
|
// Shorthand
|
||||
|
#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); } |
||||
|
|
||||
|
/**
|
||||
|
ports and functions |
||||
|
|
||||
|
added as necessary or if I feel like it- not a comprehensive list! |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
pins |
||||
|
*/ |
||||
|
|
||||
|
#define DIO0_PIN 8 |
||||
|
|
||||
|
#endif /* _FASTIO_TEENSY_H */ |
@ -0,0 +1,57 @@ |
|||||
|
#include "../persistent_store_api.h" |
||||
|
|
||||
|
#include "../../../types.h" |
||||
|
#include "../../../language.h" |
||||
|
#include "../../../serial.h" |
||||
|
#include "../../../utility.h" |
||||
|
|
||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
#if ENABLED(EEPROM_SETTINGS) |
||||
|
|
||||
|
namespace HAL { |
||||
|
namespace PersistentStore { |
||||
|
|
||||
|
bool access_start() { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool access_finish(){ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { |
||||
|
while (size--) { |
||||
|
uint8_t * const p = (uint8_t * const)pos; |
||||
|
uint8_t v = *value; |
||||
|
// EEPROM has only ~100,000 write cycles,
|
||||
|
// so only write bytes that have changed!
|
||||
|
if (v != eeprom_read_byte(p)) { |
||||
|
eeprom_write_byte(p, v); |
||||
|
if (eeprom_read_byte(p) != v) { |
||||
|
SERIAL_ECHO_START(); |
||||
|
SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
crc16(crc, &v, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
}; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) { |
||||
|
do { |
||||
|
uint8_t c = eeprom_read_byte((unsigned char*)pos); |
||||
|
*value = c; |
||||
|
crc16(crc, &c, 1); |
||||
|
pos++; |
||||
|
value++; |
||||
|
} while (--size); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endif // EEPROM_SETTINGS
|
||||
|
#endif // ARDUINO_ARCH_AVR
|
@ -0,0 +1,28 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* 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 SPI_PINS_H_ |
||||
|
#define SPI_PINS_H_ |
||||
|
|
||||
|
#define SCK_PIN 13 |
||||
|
#define MISO_PIN 12 |
||||
|
#define MOSI_PIN 11 |
||||
|
#define SS_PIN 20 //SDSS // A.28, A.29, B.21, C.26, C.29
|
||||
|
|
||||
|
#endif /* SPI_PINS_H_ */ |
@ -0,0 +1,39 @@ |
|||||
|
/**
|
||||
|
* 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/>.
|
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) |
||||
|
|
||||
|
#include "../../../Marlin.h" |
||||
|
|
||||
|
#if ENABLED(USE_WATCHDOG) |
||||
|
|
||||
|
#include "watchdog_Teensy.h" |
||||
|
|
||||
|
void watchdog_init() { |
||||
|
WDOG_TOVALH = 0; |
||||
|
WDOG_TOVALL = 4000; |
||||
|
WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN; |
||||
|
} |
||||
|
|
||||
|
#endif //USE_WATCHDOG
|
||||
|
|
||||
|
#endif |
@ -0,0 +1,38 @@ |
|||||
|
/**
|
||||
|
* 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 WATCHDOG_TEENSY_H |
||||
|
#define WATCHDOG_TEENSY_H |
||||
|
|
||||
|
//#include "../../../Marlin.h"
|
||||
|
|
||||
|
// Arduino Due core now has watchdog support
|
||||
|
|
||||
|
void watchdog_init(); |
||||
|
|
||||
|
inline void watchdog_reset() { |
||||
|
// Watchdog refresh sequence
|
||||
|
WDOG_REFRESH = 0xA602; |
||||
|
WDOG_REFRESH = 0xB480; |
||||
|
} |
||||
|
|
||||
|
#endif /* WATCHDOG_TEENSY_H */ |
@ -0,0 +1,3 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
|
||||
|
arduino --verify --board teensy:avr:teensy35:usb=serial,speed=120,opt=o1std,keys=en-us Marlin/Marlin.ino |
Loading…
Reference in new issue