My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

HAL.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #define _MSERIAL(X) Serial##X
  45. #define MSERIAL(X) _MSERIAL(X)
  46. #define Serial0 Serial
  47. #if SERIAL_PORT == -1
  48. #define MYSERIAL0 SerialUSB
  49. #elif WITHIN(SERIAL_PORT, 0, 8)
  50. #define MYSERIAL0 MSERIAL(SERIAL_PORT)
  51. #else
  52. #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration."
  53. #endif
  54. #ifdef SERIAL_PORT_2
  55. #if SERIAL_PORT_2 == -1
  56. #define MYSERIAL1 usbSerial
  57. #elif WITHIN(SERIAL_PORT_2, 0, 8)
  58. #define MYSERIAL0 MSERIAL(SERIAL_PORT_2)
  59. #else
  60. #error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration."
  61. #endif
  62. #endif
  63. #define HAL_SERVO_LIB libServo
  64. typedef int8_t pin_t;
  65. #ifndef analogInputToDigitalPin
  66. #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
  67. #endif
  68. #define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq()
  69. #define CRITICAL_SECTION_END() if (!primask) __enable_irq()
  70. #define ISRS_ENABLED() (!__get_primask())
  71. #define ENABLE_ISRS() __enable_irq()
  72. #define DISABLE_ISRS() __disable_irq()
  73. #undef sq
  74. #define sq(x) ((x)*(x))
  75. #ifndef strncpy_P
  76. #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
  77. #endif
  78. // Don't place string constants in PROGMEM
  79. #undef PSTR
  80. #define PSTR(str) ({static const char *data = (str); &data[0];})
  81. // Fix bug in pgm_read_ptr
  82. #undef pgm_read_ptr
  83. #define pgm_read_ptr(addr) (*((void**)(addr)))
  84. // Add type-checking to pgm_read_word
  85. #undef pgm_read_word
  86. #define pgm_read_word(addr) (*((uint16_t*)(addr)))
  87. // Enable hooks into idle and setup for HAL
  88. #define HAL_IDLETASK 1
  89. FORCE_INLINE void HAL_idletask() {}
  90. FORCE_INLINE void HAL_init() {}
  91. // Clear reset reason
  92. void HAL_clear_reset_source();
  93. // Reset reason
  94. uint8_t HAL_get_reset_source();
  95. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  96. #pragma GCC diagnostic push
  97. #pragma GCC diagnostic ignored "-Wunused-function"
  98. extern "C" {
  99. uint32_t freeMemory();
  100. }
  101. #pragma GCC diagnostic pop
  102. // ADC
  103. void HAL_adc_init();
  104. #define HAL_ADC_VREF 3.3
  105. #define HAL_ADC_RESOLUTION 10
  106. #define HAL_ADC_FILTERED // turn off ADC oversampling
  107. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  108. #define HAL_READ_ADC() HAL_adc_get_result()
  109. #define HAL_ADC_READY() true
  110. #define HAL_ANALOG_SELECT(pin)
  111. void HAL_adc_start_conversion(const uint8_t adc_pin);
  112. uint16_t HAL_adc_get_result();
  113. #define GET_PIN_MAP_PIN(index) index
  114. #define GET_PIN_MAP_INDEX(pin) pin
  115. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
  116. bool is_output(uint8_t pin);