My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  5. * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
  6. * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Description: HAL for Teensy 3.5 and Teensy 3.6
  24. */
  25. #pragma once
  26. #define CPU_32_BIT
  27. #include "../shared/Marduino.h"
  28. #include "../math_32bit.h"
  29. #include "../HAL_SPI.h"
  30. #include "fastio_Teensy.h"
  31. #include "watchdog_Teensy.h"
  32. #include "HAL_timers_Teensy.h"
  33. #include <stdint.h>
  34. #define ST7920_DELAY_1 DELAY_NS(600)
  35. #define ST7920_DELAY_2 DELAY_NS(750)
  36. #define ST7920_DELAY_3 DELAY_NS(750)
  37. //#undef MOTHERBOARD
  38. //#define MOTHERBOARD BOARD_TEENSY31_32
  39. #define IS_32BIT_TEENSY defined(__MK20DX256__)
  40. #define IS_TEENSY32 defined(__MK20DX256__)
  41. #define NUM_SERIAL 1
  42. #if SERIAL_PORT == -1
  43. #define MYSERIAL0 SerialUSB
  44. #elif SERIAL_PORT == 0
  45. #define MYSERIAL0 Serial
  46. #elif SERIAL_PORT == 1
  47. #define MYSERIAL0 Serial1
  48. #elif SERIAL_PORT == 2
  49. #define MYSERIAL0 Serial2
  50. #elif SERIAL_PORT == 3
  51. #define MYSERIAL0 Serial3
  52. #endif
  53. #define HAL_SERVO_LIB libServo
  54. typedef int8_t pin_t;
  55. #ifndef analogInputToDigitalPin
  56. #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
  57. #endif
  58. #define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
  59. #define CRITICAL_SECTION_END if (!primask) __enable_irq()
  60. #define ISRS_ENABLED() (!__get_PRIMASK())
  61. #define ENABLE_ISRS() __enable_irq()
  62. #define DISABLE_ISRS() __disable_irq()
  63. #ifndef strncpy_P
  64. #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
  65. #endif
  66. // Fix bug in pgm_read_ptr
  67. #undef pgm_read_ptr
  68. #define pgm_read_ptr(addr) (*((void**)(addr)))
  69. // Add type-checking to pgm_read_word
  70. #undef pgm_read_word
  71. #define pgm_read_word(addr) (*((uint16_t*)(addr)))
  72. inline void HAL_init(void) { }
  73. // Clear the reset reason
  74. void HAL_clear_reset_source(void);
  75. // Get the reason for the reset
  76. uint8_t HAL_get_reset_source(void);
  77. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  78. extern "C" {
  79. int freeMemory(void);
  80. }
  81. // SPI: Extended functions which take a channel number (hardware SPI only)
  82. // Write single byte to specified SPI channel
  83. void spiSend(uint32_t chan, byte b);
  84. // Write buffer to specified SPI channel
  85. void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
  86. // Read single byte from specified SPI channel
  87. uint8_t spiRec(uint32_t chan);
  88. // ADC
  89. void HAL_adc_init();
  90. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  91. #define HAL_READ_ADC() HAL_adc_get_result()
  92. #define HAL_ADC_READY() true
  93. #define HAL_ANALOG_SELECT(pin)
  94. void HAL_adc_start_conversion(const uint8_t adc_pin);
  95. uint16_t HAL_adc_get_result(void);
  96. #define GET_PIN_MAP_PIN(index) index
  97. #define GET_PIN_MAP_INDEX(pin) pin
  98. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)