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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * Description: HAL for Teensy 4.0 and Teensy 4.1
  25. */
  26. #define CPU_32_BIT
  27. #include "../shared/Marduino.h"
  28. #include "../shared/math_32bit.h"
  29. #include "../shared/HAL_SPI.h"
  30. #include "fastio.h"
  31. #include "watchdog.h"
  32. #include <stdint.h>
  33. #include <util/atomic.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. // ------------------------
  38. // Defines
  39. // ------------------------
  40. #ifdef __IMXRT1062__
  41. #define IS_32BIT_TEENSY 1
  42. #define IS_TEENSY41 1
  43. #endif
  44. #if SERIAL_PORT == -1
  45. #define MYSERIAL0 SerialUSB
  46. #elif SERIAL_PORT == 0
  47. #define MYSERIAL0 Serial
  48. #elif SERIAL_PORT == 1
  49. #define MYSERIAL0 Serial1
  50. #elif SERIAL_PORT == 2
  51. #define MYSERIAL0 Serial2
  52. #elif SERIAL_PORT == 3
  53. #define MYSERIAL0 Serial3
  54. #elif SERIAL_PORT == 4
  55. #define MYSERIAL0 Serial4
  56. #elif SERIAL_PORT == 5
  57. #define MYSERIAL0 Serial5
  58. #elif SERIAL_PORT == 6
  59. #define MYSERIAL0 Serial6
  60. #elif SERIAL_PORT == 7
  61. #define MYSERIAL0 Serial7
  62. #elif SERIAL_PORT == 8
  63. #define MYSERIAL0 Serial8
  64. #else
  65. #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration."
  66. #endif
  67. #ifdef SERIAL_PORT_2
  68. #if SERIAL_PORT_2 == SERIAL_PORT
  69. #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
  70. #elif SERIAL_PORT_2 == -1
  71. #define MYSERIAL1 usbSerial
  72. #elif SERIAL_PORT_2 == 0
  73. #define MYSERIAL1 Serial
  74. #elif SERIAL_PORT_2 == 1
  75. #define MYSERIAL1 Serial1
  76. #elif SERIAL_PORT_2 == 2
  77. #define MYSERIAL1 Serial2
  78. #elif SERIAL_PORT_2 == 3
  79. #define MYSERIAL1 Serial3
  80. #elif SERIAL_PORT_2 == 4
  81. #define MYSERIAL1 Serial4
  82. #elif SERIAL_PORT_2 == 5
  83. #define MYSERIAL1 Serial5
  84. #elif SERIAL_PORT_2 == 6
  85. #define MYSERIAL1 Serial6
  86. #elif SERIAL_PORT_2 == 7
  87. #define MYSERIAL1 Serial7
  88. #elif SERIAL_PORT_2 == 8
  89. #define MYSERIAL1 Serial8
  90. #else
  91. #error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration."
  92. #endif
  93. #define NUM_SERIAL 2
  94. #else
  95. #define NUM_SERIAL 1
  96. #endif
  97. #define HAL_SERVO_LIB libServo
  98. typedef int8_t pin_t;
  99. #ifndef analogInputToDigitalPin
  100. #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
  101. #endif
  102. #define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq()
  103. #define CRITICAL_SECTION_END() if (!primask) __enable_irq()
  104. #define ISRS_ENABLED() (!__get_primask())
  105. #define ENABLE_ISRS() __enable_irq()
  106. #define DISABLE_ISRS() __disable_irq()
  107. #undef sq
  108. #define sq(x) ((x)*(x))
  109. #ifndef strncpy_P
  110. #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
  111. #endif
  112. // Don't place string constants in PROGMEM
  113. #undef PSTR
  114. #define PSTR(str) ({static const char *data = (str); &data[0];})
  115. // Fix bug in pgm_read_ptr
  116. #undef pgm_read_ptr
  117. #define pgm_read_ptr(addr) (*((void**)(addr)))
  118. // Add type-checking to pgm_read_word
  119. #undef pgm_read_word
  120. #define pgm_read_word(addr) (*((uint16_t*)(addr)))
  121. // Enable hooks into idle and setup for HAL
  122. #define HAL_IDLETASK 1
  123. FORCE_INLINE void HAL_idletask() {}
  124. FORCE_INLINE void HAL_init() {}
  125. // Clear reset reason
  126. void HAL_clear_reset_source();
  127. // Reset reason
  128. uint8_t HAL_get_reset_source();
  129. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  130. #pragma GCC diagnostic push
  131. #pragma GCC diagnostic ignored "-Wunused-function"
  132. extern "C" {
  133. uint32_t freeMemory();
  134. }
  135. #pragma GCC diagnostic pop
  136. // ADC
  137. void HAL_adc_init();
  138. #define HAL_ADC_VREF 3.3
  139. #define HAL_ADC_RESOLUTION 10
  140. #define HAL_ADC_FILTERED // turn off ADC oversampling
  141. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  142. #define HAL_READ_ADC() HAL_adc_get_result()
  143. #define HAL_ADC_READY() true
  144. #define HAL_ANALOG_SELECT(pin)
  145. void HAL_adc_start_conversion(const uint8_t adc_pin);
  146. uint16_t HAL_adc_get_result();
  147. #define GET_PIN_MAP_PIN(index) index
  148. #define GET_PIN_MAP_INDEX(pin) pin
  149. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
  150. bool is_output(uint8_t pin);